Skip to content

Instantly share code, notes, and snippets.

@onjin
Last active March 6, 2019 13:19
Show Gist options
  • Save onjin/622363e47c835096fa32056e6cd022c5 to your computer and use it in GitHub Desktop.
Save onjin/622363e47c835096fa32056e6cd022c5 to your computer and use it in GitHub Desktop.
python code profiling

requirements

Install https://github.com/jrfonseca/gprof2dot

Run profiler

$ python -m cProfile -o profiler.pstats ./some/python/code.py
$ gprof2dot -f pstats profiler.pstats | dot -Tpng -o profiler.png  # generate PNG calltree image
$ pyprof2calltree -i profiler.pstats -k  # debug with kcachegrind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment