Skip to content

Instantly share code, notes, and snippets.

@dpo
Created December 5, 2010 21:37
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 dpo/729495 to your computer and use it in GitHub Desktop.
Save dpo/729495 to your computer and use it in GitHub Desktop.
Create a pdf with profile information in the form of a directed graph. Requires graphviz and gprof2dot.py
#!/bin/bash
outfile="profile-$$"
python -m cProfile -o ${outfile}.pstats $@
if [[ $? ]]; then
gprof2dot.py -f pstats ${outfile}.pstats | dot -Tpdf -o ${outfile}.png
echo "Profile graph is in ${outfile}.png"
else
echo "Profile creation aborted."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment