Skip to content

Instantly share code, notes, and snippets.

@noirbizarre
Created March 20, 2025 13:22
Show Gist options
  • Save noirbizarre/dfdfba807451015e7db72c5fd11c6690 to your computer and use it in GitHub Desktop.
Save noirbizarre/dfdfba807451015e7db72c5fd11c6690 to your computer and use it in GitHub Desktop.
Python profiling

Python profiling

Benchmarking

pytest-benchmark

https://pytest-benchmark.readthedocs.io/en/latest/

Locust

https://locust.io

Call stack profilers

cProfile

https://docs.python.org/3/library/profile.html

python -m cProfile -o reports/worker-health.profile -m pdm worker:health

pytest-profiling

https://pypi.org/project/pytest-profiling/

gprof2dot

https://github.com/jrfonseca/gprof2dot

SnakeViz

https://jiffyclub.github.io/snakeviz/

https://github.com/jiffyclub/snakeviz

snakeviz reports/command.profile

Tuna

https://github.com/nschloe/tuna

snakeviz reports/command.profile

VizTracer

https://github.com/gaogaotiantian/viztracer https://viztracer.readthedocs.io/en/latest/

pyinstrument

https://github.com/joerick/pyinstrument

pyinstrument --from-path pdm command
2023-10-18T22:44:11.873098Z [info     ] Configure structlog            [logging] mode=DEV
2023-10-18T22:44:11.873250Z [error    ] Celery Worker heartbeat file NOT found. [scripts.celery] 

  _     ._   __/__   _ _  _  _ _/_   Recorded: 00:44:10  Samples:  593
 /_//_/// /_\ / //_// / //_'/ //     Duration: 1.558     CPU time: 0.563
/   _/                      v4.6.0

Program: [...]/.venv/bin/pyinstrument --from-path pdm command

Palenteer

https://github.com/dfeneyrou/palanteer

Memory profilers

Memray

https://bloomberg.github.io/memray/

pytest-memray

https://github.com/bloomberg/pytest-memray

Memory profiler

https://github.com/pythonprofilers/memory_profiler

pytest-monitor

https://github.com/CFMTech/pytest-monitor

Visualisation

FlameGraph

https://www.brendangregg.com/flamegraphs.html

https://github.com/brendangregg/FlameGraph

Inferno

https://github.com/jonhoo/inferno

Speedscope

https://www.speedscope.app/

Python Flame Chart

https://python-flame-chart.netlify.app/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment