This project includes multiple bench modes intended for quick performance checks inside the game runtime. These are best driven through the E2E harness so results are recorded consistently and without UI timing variance.
bench: Spawns extra entrances and adjusts speed to hold a steady tick cadence. Useful for checking raw lemming throughput in a single level.bench2: Catchup-focused mode that slows down when RAF falls behind. Good for spotting perf spikes that trigger the failsafe inGameTimer.benchSequence: Runs a sequence of entrance counts and extra lemming loads. This is the default for broader performance sweeps.benchReverse: Bench mode with reverse playback. Useful for time-travel rendering costs and reverse history application.
- Use the E2E harness and run the benchmark script:
npm run bench-performance -- --mode=sequence
- Review the JSON output for max TPS, max speed, and per-sample values.
- If investigating reverse playback cost, run with
--profile=reverseor--mode=reverse.
Use the history stress test to find when the history buffer becomes too large. It runs at fixed speed factors and reports the history span and (if available) heap usage.
npm run bench-history -- --target=60000 --duration=60000
The E2E harness exposes bench metrics through window.__E2E__.getBenchMetrics()
so scripts and tests can inspect live performance data while running.
GameTimer includes a catchup slowdown path that lowers speed factor when the
RAF loop falls behind. Bench mode bench2 is the best place to verify this
behaves as intended. If the slowdown triggers too aggressively or never
triggers, adjust thresholds in GameTimer.#catchupSpeedAdjust().