profiler-cpu-query
Query Hermes CPU profiles to pinpoint JavaScript hotspots, inspect CPU within a time window, trace function callers/callees, or aggregate CPU per component. Returns markdown tables for fast debugging.
Instructions
Query Hermes CPU profile data with targeted modes for iterative investigation. Requires react-profiler-stop (and ideally react-profiler-analyze) to have been called first. Modes:
top_functions: Global CPU hotspots ranked by self-time. Optional time_window_ms to filter.
time_window: CPU breakdown for a specific time range (e.g. during a slow commit or hang).
Self-times are the summed sampling intervals of the samples that landed in the window, so they measure sampled coverage rather than the window's width and do not change if you widen the query. Every table states how many samples it covers and how much of that was idle.
call_tree: For a given function_name, show its callees and optionally callers.
component_cpu: For a given component_name, aggregate CPU activity across all its commits. Use when investigating JS CPU hotspots or correlating CPU cost with specific components. Returns a markdown table of CPU hotspots, call tree, or per-component CPU breakdown. Fails if no CPU profile is stored — run react-profiler-stop first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | Yes | Query mode: top_functions (global hotspots), time_window (CPU in a time range), call_tree (callers/callees of a function), component_cpu (CPU during a component's commits) | |
| port | No | Metro server port | |
| top_n | No | Number of results to return (default 15) | |
| device_id | Yes | Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId). | |
| function_name | No | Function name for call_tree mode | |
| component_name | No | Component name for component_cpu mode | |
| time_window_ms | No | Time window filter for time_window mode (ms since profiling started — the same clock profiler-commit-query prints) | |
| include_callers | No | For call_tree mode: also show callers of the function |