#!/usr/bin/env bash # SPDX-License-Identifier: MIT # The benchmark: the four 32X cartridges of the speed table (README), each from power-on # with sound and picture, start pressed as the lockstep's smoke cases press it. Prints each # workload's time and check, and a total. # # Usage: scripts/bench.sh [--frames N] [--repeat N] [--only NAME] # env: BENCH_BIN (default target/release/s32x-bench), SEGA32X_BIOS_DIR (the user's boot # ROMs), NO_INTRO_DIR (the "Sega - 32X" set under it), WORKLOADS (names, default all but # chaotix-nofm) set -euo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd) BIN=${BENCH_BIN:-"$ROOT/target/release/s32x-bench"} NI32="${NO_INTRO_DIR:?set NO_INTRO_DIR}/Sega - 32X" BIOS=${SEGA32X_BIOS_DIR:?set SEGA32X_BIOS_DIR} FRAMES=900 REPEAT=1 ONLY= while [ $# -gt 0 ]; do case $1 in --frames) FRAMES=$2; shift 2 ;; --repeat) REPEAT=$2; shift 2 ;; --only) ONLY=$2; shift 2 ;; *) echo "unknown argument $1" >&2; exit 2 ;; esac done PRESS="--press start@500:504 --press start@750:754" workloads=( "chaotix|$NI32/Knuckles' Chaotix (Japan, USA) (En).zip|--press start@300:304 --press start@500:504" "chaotix-nofm|$NI32/Knuckles' Chaotix (Japan, USA) (En).zip|--no-fm --press start@300:304 --press start@500:504" "vrd|$NI32/Virtua Racing Deluxe (USA).zip|$PRESS" "swa|$NI32/Star Wars Arcade (USA).zip|$PRESS" "doom|$NI32/Doom (Japan, USA) (En).zip|$PRESS" ) total=0 for w in "${workloads[@]}"; do IFS='|' read -r name cart args <<<"$w" if [ -n "$ONLY" ]; then [ "$ONLY" = "$name" ] || continue elif [ "$name" = chaotix-nofm ]; then continue; fi # shellcheck disable=SC2086 line=$("$BIN" "$cart" --bios-dir "$BIOS" --frames "$FRAMES" --repeat "$REPEAT" $args) echo "$name: $line" total=$(awk "BEGIN{print $total + $(cut -d' ' -f1 <<<"$line")}") done echo "total $total s"