Skip to content

Instantly share code, notes, and snippets.

@skyrocknroll
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyrocknroll/caf1167f860719e19ff4 to your computer and use it in GitHub Desktop.
Save skyrocknroll/caf1167f860719e19ff4 to your computer and use it in GitHub Desktop.
python profiling

@Maxy's comment on this answer helped me out enough that I think it deserves its own answer: I already had cProfile-generated .pstats files and I didn't want to re-run things with pycallgraph, so I used gprof2dot, and got pretty svgs:

$ sudo apt-get install graphviz
$ git clone https://code.google.com/p/jrfonseca.gprof2dot/ gprof2dot
$ ln -s "$PWD"/gprof2dot/gprof2dot.py ~/bin
$ cd $PROJECT_DIR
$ gprof2dot.py -f pstats profile.pstats | dot -Tsvg -o callgraph.svg

and BLAM!

It uses dot (the same thing that pycallgraph uses) so output looks similar. I get the impression that gprof2dot loses less information though:

gprof2dot example output

Python line profiler

http://www.huyng.com/posts/python-performance-analysis/

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