profile
Profile Python code to identify performance bottlenecks in CPU, memory, and GPU usage. Analyze scripts or code snippets for optimization insights.
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}
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 |