profile
Profile Python code with Scalene to identify CPU, memory, and GPU bottlenecks using script or code snippet inputs.
Instructions
Profile Python code using Scalene.
Args: type: "script" (profile a file) or "code" (profile code snippet) script_path: Required if type="script". Path to Python script code: Required if type="code". Python code to execute cpu_only: Skip memory/GPU profiling include_memory: Profile memory allocations include_gpu: Profile GPU usage (requires NVIDIA GPU) reduced_profile: Show only lines >1% CPU or >100 allocations profile_only: Comma-separated paths to include (e.g., "myapp") profile_exclude: Comma-separated paths to exclude (e.g., "test,vendor") use_virtual_time: Measure CPU time excluding I/O wait cpu_percent_threshold: Minimum CPU % to report malloc_threshold: Minimum allocation bytes to report script_args: Command-line arguments for the script
Returns: {profile_id, summary, text_summary}
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"type": "<type>"
},
"name": "profile"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | ||
| script_path | No | ||
| code | No | ||
| cpu_only | No | ||
| include_memory | No | ||
| include_gpu | No | ||
| reduced_profile | No | ||
| profile_only | No | ||
| profile_exclude | No | ||
| use_virtual_time | No | ||
| cpu_percent_threshold | No | ||
| malloc_threshold | No | ||
| script_args | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||