Skip to content

ui: add built-in in-game benchmark - #1163

Open
jfpaardoo wants to merge 1 commit into
Revivedx:testfrom
jfpaardoo:feat/builtin-benchmark
Open

jfpaardoo wants to merge 1 commit into
Revivedx:testfrom
jfpaardoo:feat/builtin-benchmark

Conversation

@jfpaardoo

Copy link
Copy Markdown
Contributor

What this changes

Implements the built-in in-game benchmark suite directly in the F1 menu (Benchmark page), bringing the canonical routes and metrics from tools/perf_routes.py to players without needing Python or developer mode.

  • runtime/benchmark.h, runtime/benchmark.c:
    • Defines the 7 canonical Hyrule routes (plateau, kakariko, field, rito, castle, hateno, korok) plus a Current spot mode, Quick suite (3 routes), and Single route mode.
    • Non-blocking per-frame state machine (bench_frame): saves the player's position, hour of day, and FPS/VSync/Frame generation/overlay settings; optionally uncaps FPS/VSync/Frame gen during measurement; teleports, activates fly hover + fixed time of day (10:00), aims camera via control_look_start, warms up, records per-frame microsecond deltas (BENCH_MAX_FRAMES), and cleanly restores Link and all settings afterwards (or on early cancel with Esc / B), reopening the Benchmark results page.
    • Registers RT_ON_RESET(bench_reset) to clear per-boot state and restore temporary overrides on reboot.
    • Computes average FPS, 1% low, 0.1% low, avg/median/p95/p99/min/max frame time (ms), hitch count (> max(2 * median, 33.33 ms)), 120-bin max-preserving frame-time sparkline, and peak VRAM/RAM/GPU telemetry per route and combined overall.
    • Formats a Markdown report (bench_format_markdown) and writes timestamped CSV reports under <data_root>/benchmarks/ (bench_save_csv).
  • runtime/control.c, runtime/control_input.c: drives bench_frame, control_tp_frame, look_step, and fly-mode input/camera aiming while a benchmark is active even when developer mode is off.
  • runtime/ui/benchmark_ui.h, runtime/ui/benchmark_ui.mm, runtime/ui/menu.mm:
    • Adds the Benchmark page (ID 15) to the F1 menu with suite configuration, KPI summary cards, clickable per-route results table, custom frame-time graph with 30/60/120 FPS reference lines, and Markdown clipboard / CSV export actions.
    • Adds a compact top-right translucent progress HUD during active runs (BENCHMARK i / N, current phase & progress bar, live FPS/ms & sparkline, Esc / B cancel).
  • runtime/ui/i18n/*.inc: adds translations for all new UI strings across all 13 languages.
  • tests/test_benchmark.c, Makefile: adds unit tests (test-benchmark) covering steady frame rates, hitches, 1%/0.1% lows, percentiles, sparkline max-preservation, route metadata, and Markdown export.

How it was tested

On Windows 11 (NVIDIA GeForce RTX 3050 Laptop GPU, MSYS2 UCRT64 clang):

  • tools/venv/Scripts/python.exe tools/i18n_check.py: 1598 menu texts, 0 missing, 0 unused across all 13 languages.
  • make -j8: built build/savagewind.exe cleanly and linked build/swgame.dll (1.9.0, 269 sites).
  • make -j8 test-benchmark: PASS: bench_compute_stats, hitches, 1%/0.1% lows, sparkline, markdown, routes.
  • make -j8 test-pc-controls: all tests in test_pc_controls, test_options_pointer, and test_pc_settings passed.
  • Unattended startup smoke test (1.9.0, SAVAGEWIND_EXIT_AT=300): reached frame 249 (124.0 fps) cleanly with exit code 0.
  • git diff --check: clean.

Checklist

  • Based on the latest test and opened against test
  • Built and run locally, and checked in the game
  • No game files, keys, firmware, generated game code or save files in the changes

Copilot AI balanced review requested due to automatic review settings November 26, 2026 18:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@rydof

rydof commented Nov 26, 2026

Copy link
Copy Markdown

Tested this PR on Linux (x86-64, NVIDIA Quadro T1000, driver 620.73.04, clang 23, BotW 1.9.0). Great feature overall—I ran into a few issues while building and testing it:

  1. make test-control fails to link: runtime/control.c now calls bench_frame(), bench_active(), and control_tp_frame(), so tools/test_control.c needs stubs for those three symbols.
  2. Starting from the menu / in-game pause menu:
    • Starting from the title/main menu lets the benchmark start even though the player isn't in the world yet, so teleports can't run.
    • Starting from in-game via BotW's Options menu closes the F1 overlay, but leaves BotW's own Pause Menu open and impossible to close while the benchmark is running.
  3. Save safety / standalone mode: Teleporting across Hyrule during a benchmark can trigger BotW autosaves on the active save. Blocking save writes while the benchmark is running—and ideally letting it launch cleanly outside of a save with a cinematic camera—would make it safer and much nicer to use.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants