Skip to content

Instantly share code, notes, and snippets.

@taoliu
Forked from anonymous/pyprofile
Created June 19, 2011 20:06
Show Gist options
  • Save taoliu/1034674 to your computer and use it in GitHub Desktop.
Save taoliu/1034674 to your computer and use it in GitHub Desktop.
pyrprofile: profile Python script
#!/usr/bin/env bash
## pyprofile: profile Python script
## $Revision$
## Copyright 2011 Michael M. Hoffman <[email protected]>
## Modified by Tao Liu: Correctly get the command name.
set -o nounset
set -o pipefail
set -o errexit
if [ $# == 0 ]; then
echo usage: "$0" CMDLINE...
exit 2
fi
MAIN=`basename $1`
PROF="${MAIN}.$(date +%Y%m%dT%H%M%S).prof"
python -m cProfile -o "$PROF" "$@"
python -m pstats "$PROF"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment