record_profile
Profile a Python process or command by recording stack samples to identify performance bottlenecks.
Instructions
Record a sampling profile of a Python process or command.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gil | No | Only include traces holding the GIL. | |
| pid | No | Process ID to sample. Use this OR command, not both. | |
| idle | No | Include idle threads. | |
| rate | No | Samples per second (default 100). | |
| native | No | Include native/C extension frames if supported on this platform. | |
| command | No | Command to run and sample, e.g. ["python", "script.py"]. Use this OR pid. | |
| duration | No | How many seconds to sample (default 5, recommended 5-60). | |
| subprocesses | No | Include child Python processes. | |
| output_format | No | One of "speedscope" (JSON), "flamegraph" (SVG), "raw" (text), "chrometrace". | speedscope |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |