Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from jbaicoianu/mamebench
Added mame benchmarking scripts
- Loading branch information
Showing
5 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
MAMEBench | ||
========= | ||
This is a set of shell scripts which make it simple to run parallel benchmarks on all roms in a directory. | ||
|
||
Usage: ./mamebench.sh <romdir> <benchfile> [-t <benchtime>] [-j <threads>] [-p <pattern>] | ||
|
||
|
||
Examples: | ||
|
||
# Benchmark all roms in /data/roms for 45 seconds each, using 4 threads | ||
$ ./mamebench.sh /data/roms benchmark-20150519.tsv -t 45 -j 4 | ||
|
||
# Benchmark all sf2 variants in /data/roms for 90 seconds each, using 6 threads | ||
$ ./mamebench.sh /data/roms benchmark-20150519.tsv -t 90 -j 6 -p sf2* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
ROMDIR=$1 | ||
LOGFILE=$2 | ||
BENCHTIME=30 | ||
THREADS=4 | ||
PATTERN="*" | ||
|
||
shift 2 | ||
while getopts "t:p:" opt; do | ||
case "$opt" in | ||
t) | ||
BENCHTIME=$OPTARG | ||
;; | ||
p) | ||
PATTERN=$OPTARG | ||
;; | ||
esac | ||
done | ||
|
||
for I in "$ROMDIR"/$PATTERN.zip; do | ||
GAME=$(basename "${I/\.zip/}") | ||
echo "./mamebench-game.sh \"${ROMDIR}\" \"${LOGFILE}\" $GAME -t $BENCHTIME" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
ROMDIR=$1 | ||
LOGFILE=$2 | ||
GAME=$3 | ||
|
||
BENCHTIME=30 | ||
|
||
shift 3 | ||
while getopts "t:j:" opt; do | ||
case "$opt" in | ||
t) | ||
BENCHTIME=$OPTARG | ||
;; | ||
esac | ||
done | ||
|
||
MAMEOUT=$(SDLMAME_DESKTOPDIM=800x600 SDL_VIDEODRIVER=dummy SDL_RENDER_DRIVER=software mame -rompath "$ROMDIR" -bench $BENCHTIME $GAME | tr -d '\n' | sed 's/.*Average speed: //' | sed 's/\% .*$/%/' ) | ||
FULLNAME=$(mame -listfull $GAME |tail -1 |sed -r 's/^.*"(.*)"$/\1/g') | ||
echo "$GAME\t$FULLNAME\t$MAMEOUT" >> "${LOGFILE}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/sh | ||
|
||
if [ $# -lt 2 ]; then | ||
echo "Usage: $0 <romdir> <logfile> [-t <benchtime>] [-j <threads>]" | ||
exit 1 | ||
fi | ||
|
||
ROMDIR=$1 | ||
LOGFILE=$2 | ||
BENCHTIME=30 | ||
THREADS=4 | ||
PATTERN="*" | ||
|
||
shift 2 | ||
while getopts "t:j:p:" opt; do | ||
case "$opt" in | ||
t) | ||
BENCHTIME=$OPTARG | ||
;; | ||
j) | ||
THREADS=$OPTARG | ||
;; | ||
p) | ||
PATTERN=$OPTARG | ||
;; | ||
esac | ||
done | ||
|
||
if [ ! -d "$ROMDIR" ]; then | ||
echo "Could not find rom directory: $ROMDIR" | ||
exit 1 | ||
fi | ||
|
||
NUMROMS=$(ls "$ROMDIR" |wc -l) | ||
|
||
echo "Benchmarking $NUMROMS roms in $ROMDIR for $BENCHTIME seconds ($THREADS threads)" | ||
|
||
./mamebench-buildqueue.sh "$ROMDIR" "$LOGFILE" -t $BENCHTIME -p "$PATTERN" | ./procspawn.sh $THREADS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
if [ "$1" = "" ]; then | ||
echo "Usage: $0 <NUMPROCS>" | ||
exit | ||
fi | ||
NUMPROCS=$1 | ||
CURRPROCS=0 | ||
|
||
ALLPROCS= | ||
|
||
trap 'echo -n "Killing processes:"; for I in $ALLPROCS; do echo -n " $I"; kill $I; done; echo " done"; exit 1' SIGINT | ||
trap 'NUMPROCS=$(( $NUMPROCS + 1 )); echo "Increased NUMPROCS to ${NUMPROCS}"' SIGUSR1 | ||
trap 'NUMPROCS=$(( $NUMPROCS - 1 )); echo "Decreased NUMPROCS to ${NUMPROCS}"' SIGUSR2 | ||
|
||
while read -r CMD; do | ||
while [ $CURRPROCS -ge $NUMPROCS ]; do | ||
STILLRUNNING= | ||
STILLRUNNINGCNT=0 | ||
for PID in $ALLPROCS; do | ||
if [ -e /proc/$PID ]; then | ||
STILLRUNNING="$STILLRUNNING $PID" | ||
STILLRUNNINGCNT=$(( $STILLRUNNINGCNT + 1 )) | ||
fi | ||
done | ||
if [ "$ALLPROCS" = "$STILLRUNNING" ]; then | ||
sleep 1 | ||
else | ||
ALLPROCS=$STILLRUNNING | ||
CURRPROCS=$STILLRUNNINGCNT | ||
fi | ||
done | ||
|
||
sh -c "$CMD" & | ||
NEWPID=$! | ||
echo "Spawned '$CMD' ($NEWPID)" | ||
ALLPROCS="$ALLPROCS $NEWPID" | ||
CURRPROCS=$(( $CURRPROCS + 1 )) | ||
done | ||
wait | ||
|
||
echo COMPLETE |