mit einem Klick
pyspy
// Profile the execution time of a Python script using py-spy and visualize the result with speedscope. Use when the user wants to benchmark performance, find slow code paths, or profile CPU time.
// Profile the execution time of a Python script using py-spy and visualize the result with speedscope. Use when the user wants to benchmark performance, find slow code paths, or profile CPU time.
Profile the memory usage of a Python script using memray and visualize a temporal flamegraph in the browser. Use when the user wants to investigate memory consumption, find leaks, or understand allocation patterns.
Profile Python import time using profimp and open a waterfall HTML report. Use when investigating slow startup or wanting to identify which imports are most expensive.
| name | pyspy |
| description | Profile the execution time of a Python script using py-spy and visualize the result with speedscope. Use when the user wants to benchmark performance, find slow code paths, or profile CPU time. |
| compatibility | Requires the pixi profiling environment (pixi run -e profiling). Speedscope must be installed separately (npm install -g speedscope). sudo is required on macOS. |
| allowed-tools | Bash(pixi run -e profiling pyspy:*) Bash(pixi run -e profiling speedscope:*) Bash(sudo pixi run -e profiling pyspy:*) |
Ask the user which script to profile (full or relative path).
Run py-spy to record the profile. The output is always written to profile.speedscope.json in the current directory.
Linux (no sudo needed):
pixi run -e profiling pyspy script.py
macOS (sudo required — py-spy needs to attach to the process):
sudo pixi run -e profiling pyspy script.py
If sudo fails to find the pixi environment, use absolute paths:
sudo /path/to/.pixi/envs/profiling/bin/py-spy record --gil \
-o profile.speedscope.json --format speedscope \
-- /path/to/.pixi/envs/profiling/bin/python script.py
Open the result in speedscope:
pixi run -e profiling speedscope
This opens profile.speedscope.json in the browser via the local speedscope CLI.
cp profile.speedscope.json profile-before.speedscope.json--gil records only time when the GIL is held (Python-level CPU time). Drop it to include C extension time.npm install -g speedscope