So, here is a first shot :
#!/bin/bash
# read parameters
# $1 is the core
RA_CORE="-L /usr/lib/libretro/$1_libretro.so"
# $2 is the rom
RA_ROM="$2"
# Consider the game should run at 60Hz
FPS=60
# Start the emu
NB_FRAMES=600
RA_OPTS="--verbose --max-frames=${NB_FRAMES}"
RA_CONFIG="--config /recalbox/share/system/configs/retroarch/retroarchcustom.cfg"
RA_OUTPUT_LOG=/tmp/ra.log
rm $RA_OUTPUT_LOG
/usr/bin/time -v /usr/bin/retroarch $RA_OPTS $RA_CORE $RA_CONFIG "$RA_ROM" > $RA_OUTPUT_LOG 2>&1
# Get the emulator output
FRAMES_EXPECTED=`grep "[INFO] Threaded video stats" "$RA_OUTPUT_LOG" | sed "s+.*Frames pushed: \([0-9]*\).*+\1+"`
FRAMES_DROPPED=`grep "[INFO] Threaded video stats" "$RA_OUTPUT_LOG" | sed "s+.*Frames dropped: \([0-9]*\).*+\1+"`
FRAMES_RENDERED=$(($FRAMES_EXPECTED - $FRAMES_DROPPED))
TIME_RUN=`grep "Elapsed (wall clock) time (h:mm:ss or m:ss):" "$RA_OUTPUT_LOG" | sed "s/.*: \([0-9]*\)m \([0-9]*\)\.\([0-9]*\)s/\1 \2\ \3/"`
NB_MINS=`echo $TIME_RUN | cut -d ' ' -f 1`
NB_SECS=`echo $TIME_RUN | cut -d ' ' -f 2`
NB_CENS=`echo $TIME_RUN | cut -d ' ' -f 3`
CPU_LOAD=`grep "Percent of CPU this job got:" "$RA_OUTPUT_LOG" | sed "s/.*: \([0-9]*\)%.*/\1/"`
# Do what we need
# The game should have run for NB_FRAMES / FPS seconds, how long did it really take ?
EXPECTED_TIME=$(($NB_FRAMES / $FPS))
REAL_TIME=$(($NB_MINS * 60 + $NB_SECS))
OVERHEAD=$(($REAL_TIME - $EXPECTED_TIME))
# Looks like RA start emulation at [INFO] Initializing rewind buffer with size: 10 MB
# or [INFO] Loading history file: [/recalbox/share/system/configs/retroarch/content_image_history.lpl].
# And it ends at [INFO] Saved core options file to "/recalbox/share/system/configs/retroarch/cores/retroarch-core-options.cfg"
echo "$FRAMES_EXPECTED - $FRAMES_DROPPED = $FRAMES_RENDERED ($EXPECTED_TIME + $OVERHEAD / $CPU_LOAD)"
echo -n "1st score (100 max):"
python -c "print round(100*$FRAMES_RENDERED/$NB_FRAMES*$NB_FRAMES/$FPS/${REAL_TIME}.${NB_CENS}, 2)"
The final result is a mark out of 100. Shouldn't be above 100. 100 would mean instant load of retroarch + start of the game, which is nearly impossible.
The basic idea : retroarch is run for 600 frames (assume the game is 60Hz). Then compute a few details :
- frames rendered
- frames dropped
- total time elapsed
- CPU %
Made a few tests with killing blade (the PGM logo is already stuttering on a non overclocked pi3)
Pi3 output example:
# bash recalbox-bench.sh fba ../roms/fba_libretro/killbldp.zip
600 - 0 = 600 (10 + 4 / 88)
1st score (100 max):67.98
C2 output example:
# bash recalbox-bench.sh fba ../roms/fba_libretro/killbld.zip
600 - 0 = 600 (10 + 2 / 69)
1st score (100 max):81.23
Small explanation on the first result line
600 : number of frames expected
0 : number of frames dropped
10 : expected run time (600 frames at 60 Hz)
2 : run time overhead (means the full length of retroarch took 12s, despite i'm not showing the rest of the value but do have it in the script)
69 : CPU percentage
So from here you can notice:
- the pi3 took something like 14 to 15s for the overall launch of RA + ROM execution + quit RA whereas it took 12 to 13s on the C2
- the PGM logo was consuming 88% on pi3 vs 69% on the C2. And I tell you : the sound doesn't stutter on the C2
Overall, this bench doesn't look that bad for now