Measure a browser game's performance with real numbers before optimizing. FPS, average / p95 / p99 / worst frame times, frames over budget, long tasks, script vs layout time, update vs render split, heap and garbage per second, DOM nodes and listeners, CPU throttling to approximate phones, and a drop-in probe that also works for WebGL games in the viewer's browser. Use for "is it fast enough", ...
Download skill (.zip) Files on GitHubGame performance profiling
Measure first, then optimize the biggest cost (game-performance-optimization), then measure again with the same test.
2D / DOM games: sandbox profile
python3 <skill>/scripts/profile.py http://localhost:8000/ --seconds 10 --hold ArrowRight
python3 <skill>/scripts/profile.py http://localhost:8000/ --throttle 4 # ≈ mid-range phone CPU
python3 <skill>/scripts/profile.py http://localhost:8000/ --start "Enter" --json
Output: fps; avg, p95, p99 and worst frame time; frames over 33 ms; main-thread time per second for script and style/layout; long tasks (> 50 ms); heap at start, peak and after GC; DOM nodes and event listeners; plus a verdict.
Any game (including WebGL) in the viewer’s browser
Add assets/perf-probe.js (or load it only with ?perf):
if (location.search.includes("perf")) import("./perf-probe.js");
// optional split: __perfMark.start("update"); update(dt); __perfMark.end("update"); same for "render"
It logs a line every 5 s: [perf] fps 58.9 · avg 16.9 ms · p95 18.2 · p99 24.1 · worst 41 · long tasks 1 · heap 23 MB · update 2.1 ms · render 9.8 ms.
Read it with read_preview_console while the viewer plays (or control_preview to play it), and from window.__perf.
Reading the numbers
| Number | Good | Problem means |
|---|---|---|
| avg frame | ≤ 16.7 ms (60 fps), ≤ 8 ms on desktop for headroom | Too much work per frame |
| p99 / worst | < 25 ms / < 50 ms | Stutters: GC, loading mid-game, shader compile, long tasks |
| Long tasks | 0 during play | Big synchronous work: level generation, JSON parsing, image decoding |
| Heap peak − start | small | Garbage per frame → pooling, no allocation in the loop |
| Heap after GC rising | flat | A leak → game-memory-leak-detection |
| update vs render | either < 8 ms | Tells you whether to fix logic (CPU) or drawing (GPU / canvas) |
| Style/layout time | ~0 for canvas games | DOM changes every frame (HUD in HTML with layout thrash) |
Also look at: three.js renderer.info.render.calls (draw calls < ~200 on phones), triangles, texture memory.
Rules
- Same scenario, same length, same size, before and after. Report both numbers.
- Sandbox numbers are a guide. Phones are slower and heat up: confirm on a real device via the viewer’s preview.
- Profile the heaviest moment (boss fight, most enemies, big explosion), not the title screen.
- Report like: “Phone-throttled p99 went from 41 ms to 19 ms after pooling bullets; avg 15.2 → 9.8 ms.”