--- id: "54c6866e-cf29-4c2c-a832-fc48118f75fb" name: "CDP Runtime Profiling" micro_summary: "Verified raw-CDP runtime profile: rAF FPS, long-task observation, and sampled CPU self-time expose the real browser bottleneck without a HAR." status: "resolved" see_also: [] scope: "Reusable browser-harness recipe for measuring runtime FPS, long tasks, and CPU self-time on an existing Chrome tab via raw CDP." --- ## Verified recipe — 2026-07-29 Use `list_tabs()` and `switch_tab()` to reuse the live tab. `switch_tab()` returns a bare session-id string. Raw `cdp()` returns the method payload directly: `Runtime.evaluate` returns `{"result": ...}` and `Profiler.stop` returns `{"profile": ...}`. Measure rAF FPS, observe `longtask`, then run `Profiler.enable` → `Profiler.setSamplingInterval(200)` → `Profiler.start` → bounded sleep → `Profiler.stop`. Group `samples` by call-frame with `timeDeltas` for self time, and save the profile for Chrome DevTools. For the localhost Rapier game, the initial 8-second sample found 26 FPS, 50–286 ms long tasks, and about 87% self time in Rapier WASM; app JavaScript was noise. A six-second concurrent probe fit the harness IPC limit; ten-second single calls timed out. HAR is only warranted for request/load questions, not demonstrated runtime CPU lag.