Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Profiling

I routinely have to search around for what profiling tool I enjoy using and I’ve found that I enjoy using gprof2dot along with the standard library’s cProfile.

This page is derived from this StackOverflow answer.

pip install gprof2dot
python -m cProfile -o profile.pstats <script_name>.py
gprof2dot -f pstats profile.pstats | dot -Tsvg -o profile_results.svg

And you can easily visualize the output by doing:

eog profile_results.svg

Quick and easy profiling, the way it should be.


Written by Dylan Colli