stop_profiling
Stop the CPU profiler, save a .cpuprofile, and return long tasks, top scripts, functions, and self/total times to identify page performance culprits.
Instructions
Stop the CPU profiler started by start_profiling, save a .cpuprofile under $STATE_DIR/logs//profiles/ (its path is in the result; open it as a flame graph in the DevTools Performance panel or speedscope.app) and return the culprits: long tasks (>=50ms) split into JS vs browser-native (parse/style/layout) vs GC time with their top scripts, top JS functions and heaviest JS stack, top functions by self and total time (with url:line:col), and self time per script. Pass the same tabIndex given to start_profiling. If page JS is hung, the renderer can't answer until it yields, so after terminateAfterMs the running script is terminated to get the profile out (terminated in the result says so); set it to 0 to never terminate. top caps each ranked list, so raise it when the culprit isn't in the first 15, and keep timeout a few seconds above terminateAfterMs so a large profile has time to transfer. The file is deleted with the session by close_browser_session. Fails if start_profiling wasn't called on that tab.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| top | No | How many entries to return in each ranked list. Default 15. | |
| timeout | No | Milliseconds the whole stop call may take before failing. Default 30000. | |
| tabIndex | No | The tab passed to start_profiling, by its 0-based list_pages index. Default: the active tab. | |
| sessionId | Yes | The id returned by open_browser_session. Errors if no open session has it. | |
| terminateAfterMs | No | Milliseconds to wait for hung page JS before terminating it; 0 never terminates. Default 5000. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Where the .cpuprofile was saved. | |
| busyMs | Yes | ||
| samples | Yes | ||
| topSelf | Yes | ||
| topTotal | Yes | ||
| longTasks | Yes | ||
| durationMs | Yes | ||
| terminated | Yes | Whether hung page JS was terminated to collect the profile. | |
| topScripts | Yes |