Skip to content

Add a ?bench mode to the browser page: a scripted frame-rate run - #64

Merged
dmccoystephenson merged 2 commits into
masterfrom
bench-mode
Oct 24, 2026
Merged

dmccoystephenson merged 2 commits into
masterfrom
bench-mode

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Adds a ?bench URL mode so frame rates can be measured on real hardware (a desktop GPU, a phone) in one tap. CI and headless Chromium only have SwiftShader, so no real numbers exist yet.

What it does. After the page loads, ?bench opens the walkers (seed 7) from their first tick and turns the camera once around the grid (closing in and back out) for 15 s after a warm-up (at least 1 s and 30 frames, with the camera held at the start of the path, so first-frame shader compiles are not counted). The camera path is a function of the time into the run only (each frame turns and zooms by the step since the last), so runs on different devices are comparable. No C++ change: the existing envlib_rotate / envlib_zoom / envlib_home exports drive it. A card then shows:

  • fps, frame time median / p95 (from requestAnimationFrame intervals; capped by the display's refresh rate)
  • the page's own work per frame (the engine's rAF callbacks, timed on the main thread)
  • GPU time per frame from EXT_disjoint_timer_query_webgl2, where the browser offers it
  • canvas CSS size × devicePixelRatio and the drawing-buffer size, the WEBGL_debug_renderer_info renderer string, user agent, page version (the arcade's version.txt)
  • a Copy results button (navigator.clipboard.writeText in the click handler, falling back to selecting the text), Run again, Close

Nothing is sent anywhere. ?bench=30 runs for 30 s. The card puts its buttons above the details so the Copy button is on a phone's screen without scrolling.

How. strata/web/bench.js is the harness; it loads before the engine's script and, in bench mode only, wraps requestAnimationFrame so the engine's frames can be timed and bracketed with timer queries. Without ?bench the page is unchanged (a bench run does not overwrite the remembered world either).

Tests. strata/web/smoke/bench.cjs runs a 3 s bench in headless Chromium on the desktop and iPhone 13 profiles and checks that the run finishes, frames were timed, the card shows its numbers, the Copy button is at least 44 px tall and on screen, the card fits the screen width, and Copy puts the text on the clipboard. The numbers are not checked or kept (SwiftShader). Locally, the build, the view tests under Node, the existing smoke test (desktop) and the bench smoke (desktop + iPhone 13) passed.


drafted by Claude on behalf of Daniel Stephenson

🤖 Generated with Claude Code

https://claude.ai/code/session_01S6kaEL7kt5Fverjb6didBH

dmccoystephenson and others added 2 commits October 24, 2026 15:31
Opening the page with ?bench opens the walkers (seed 7) from their first
tick and turns the camera once around the grid, closing in and back out,
for 15 seconds after a warm-up (at least 1 s and 30 frames), then shows a
card with the frame rate, frame time (median, p95), the page's own work
per frame, GPU time from EXT_disjoint_timer_query_webgl2 where offered,
the canvas size and device pixel ratio, the GPU's name and the user
agent, with a "Copy results" button. Nothing leaves the device.

strata/web/bench.js holds the harness; it wraps requestAnimationFrame
before the engine loads so the engine's frames can be timed.
strata/web/smoke/bench.cjs checks in CI that a short run finishes and
shows its card on a desktop and an iPhone 13 profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S6kaEL7kt5Fverjb6didBH
Headless Chromium draws with SwiftShader, which can take seconds a frame
on a small runner: the run gets 7 minutes and the card's screenshot 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S6kaEL7kt5Fverjb6didBH
@dmccoystephenson
dmccoystephenson merged commit 2b069e9 into master Oct 24, 2026
3 checks passed
@dmccoystephenson
dmccoystephenson deleted the bench-mode branch October 24, 2026 22:08
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.

1 participant