Ronan's Tech Blog

Mar 01, 2019

Quick useful python profiling

Profiling your process

python -m cProfile -o profile_data.pstats my_program.py

Run python like this and it will create a file full of profiling stats.

Viewing the data

SnakeViz rocks. It's a lovely little visualisation tool that makes it very easy to see where your time is going

pip install snakeviz
snakeviz profile_data.pstats

This will launch a web server and your browser to interactively inspect the results. Enjoy!

SnakeViz sunburst view screenshot

SnakeViz icicle view screenshot

Click to read and post comments