perf
Measures a page's frame time, FPS, draw calls, triangles and asset size against a budget to diagnose stutter and test rendering variants or runtime optimizations.
Instructions
Measures the open page's frame time (fps), draw calls, triangles and asset size against a budget (desktop by default): it is for a frame a reply reports over budget, or a user who asks about performance (stutter, low fps). To find what costs the frame, give variants: each is measured on a fresh page against the baseline, in this one call, with named objects hidden, a pixel ratio, code run with renderer and scene (shadows or antialias off, a material swapped), or a query the page loads with ("noshadow&pr=0.5", for switches the game reads at load); no reopening or reload code needed. Sampling waits until no element covers the canvas (a loading screen), up to 15 s of the page running, and the load line says what it waited for or sampled under. With optimize: true it instead tries the @paprika3d/three-runtime switches one at a time: resolution (lowers the pixel ratio while frames run over budget), defaults (pixel ratio capped at 2, shaders compiled up front, shadow maps redrawn only when a caster moves), instancing (still meshes that share a geometry and material drawn as one), lod (simpler versions of meshes over 10,000 triangles at a distance) and dispose (frees the GPU memory of removed objects). instancing and lod stay only when frames get faster, the others unless they slow frames. A switch is reverted if a saved test that passed without it fails with it, and defaults, instancing and dispose also if they change the picture; a kept resolution or lod that changes it comes with before and after pictures. What it keeps goes in the project's game-runtime.json, which the runtime reads at every load, so it lasts until that file changes; it ends with the final test of game-tests.json when the project has one. On a game without the runtime it changes nothing and says how to import it.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "perf"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| game | No | The name the game was opened under with the `open` tool, to act on ("main" by default; a subagent uses its own). | |
| costs | No | Also list the main scene's visible content by named group (an object goes by its nearest named ancestor, as `look` names it): triangles, those casting shadows, draw calls and texture MB, the 12 groups with the most triangles and the rest in one line. Counted, not timed, with no frustum culling; `variants` with `hide` times a group. | |
| budget | No | desktop, mobile, quest, site (a 3D website: first scene frame within 3 s on fast-4g unless `network` says otherwise, 1 MB of script, 4 MB of assets), or limits to override: { frameMs, assetMB, triangles, drawCalls, textureMax, pixelRatioMax, firstSceneFrameMs, scriptMB }. | |
| network | No | Also time a first visit on this network, in real time with no cache: slow-4g, fast-4g or 3g (Chrome DevTools' presets), broadband (20 Mbps both ways, 40 ms), or { downKbps, upKbps, latencyMs } (upKbps defaults to downKbps). The reply names its numbers and whether a software renderer drew it, and says when the first scene frame came, which bytes came before it by kind (as sent: the harness's own server does not compress, a CDN does) and when an overlay over the canvas went. CPU `throttle` is separate. | |
| optimize | No | Try the runtime switches and keep those that help (above). Of the other fields it takes only `budget`. | |
| throttle | No | Slow the page's JavaScript this many times, as on a weak laptop (4 is a typical one); GPU work is not slowed. | |
| variants | No |