Skip to content

Instantly share code, notes, and snippets.

@mcouthon
Last active December 30, 2018 12:44
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 mcouthon/ae810d05722829c7116efa75253ef6e1 to your computer and use it in GitHub Desktop.
Save mcouthon/ae810d05722829c7116efa75253ef6e1 to your computer and use it in GitHub Desktop.
A convenience function to profile a python script
# This is the path to snakeviz executable in a dedicated venv
alias snake='/Users/pavel/dev/venvs/snakeviz/bin/snakeviz'
profile() {
tmp_file=$(mktemp)
python -m cProfile -o $tmp_file "$@"
snake $tmp_file
rm $tmp_file
}
# To use, simply run:
# >>> profile PATH_TO_SCRIPT.py ARG1 ARG2 ARG3...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment