test(bench): SponzaBench harness + #40→HEAD perf measurement (#155)

Headless benchmark around the native Sponza RT scene: times setup and a
measured Render() loop over the full multi-mesh atrium, prints BENCH
metrics, and exits. Includes run-bench.sh and a README documenting the
methodology and the measured net gain from #40 to current master.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
catbot 2026-06-18 19:35:54 +00:00
commit 619e39369d
7 changed files with 616 additions and 0 deletions

View file

@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Repeated-measurement harness for SponzaBench. Runs the binary in $BINDIR
# REPS times for a given mesh cap and reports the median (and min/max) of
# each BENCH metric. Validation is force-disabled via the loader (it adds
# huge, version-dependent overhead) and present mode is uncapped so frame
# time reflects real work rather than the compositor's vblank.
#
# Usage: run-bench.sh <bindir> <label> <meshes> <reps> [--cold]
# --cold deletes pipeline_cache.bin before EACH run (cold-compile path).
set -u
BINDIR="$1"; LABEL="$2"; MESHES="$3"; REPS="$4"; COLD="${5:-}"
cd "$BINDIR" || exit 1
declare -A vals
metrics="setup_ms fps frame_mean_ms frame_p50_ms frame_p99_ms peak_rss_kb"
for m in $metrics; do vals[$m]=""; done
for ((i=0;i<REPS;i++)); do
[ "$COLD" = "--cold" ] && rm -f pipeline_cache.bin
out=$(VK_LOADER_LAYERS_DISABLE='~all~' CRAFTER_PRESENT_IMMEDIATE=1 \
BENCH_WARMUP=200 BENCH_FRAMES=2000 BENCH_MESHES="$MESHES" \
./SponzaBench 2>/dev/null)
for m in $metrics; do
v=$(echo "$out" | awk -v k="$m" '$1=="BENCH" && $2==k {print $3}')
vals[$m]="${vals[$m]} $v"
done
done
med() { tr ' ' '\n' | grep -v '^$' | sort -n | awk '{a[NR]=$1} END{print a[int((NR+1)/2)]}'; }
lo() { tr ' ' '\n' | grep -v '^$' | sort -n | head -1; }
hi() { tr ' ' '\n' | grep -v '^$' | sort -n | tail -1; }
echo "## $LABEL (meshes=$MESHES reps=$REPS ${COLD})"
printf "%-15s %12s %12s %12s\n" metric median min max
for m in $metrics; do
echo -n "$(printf '%-15s' "$m") "
printf "%12s %12s %12s\n" \
"$(echo "${vals[$m]}" | med)" "$(echo "${vals[$m]}" | lo)" "$(echo "${vals[$m]}" | hi)"
done
echo