Debian Codegraph @

test/pyprofile

raw
1 #!/usr/bin/env bash
2
3 ## pyprofile: profile Python script
4
5 ## $Revision$
6 ## Copyright 2011 Michael M. Hoffman <[email protected]>
7 ## Modified by Tao Liu: Correctly get the command name.
8
9 set -o nounset
10 set -o pipefail
11 set -o errexit
12
13 if [ $# -lt 2 ]; then
14 echo usage: "$0" PROF CMDLINE...
15 exit 2
16 fi
17
18 PROF=$1
19 MAIN=`basename $2`
20 CMD=( $@ )
21 CMD=${CMD[@]: 1}
22
23 # run CMD with cProfile
24 python3 -m cProfile -o $PROF $CMD
25
26 # brief the profile
27 ./pyprofile_stat $PROF tottime > ${PROF/.prof/}.tottime
28 ./pyprofile_stat $PROF calls > ${PROF/.prof/}.calls
29 ./pyprofile_stat $PROF cumulative > ${PROF/.prof/}.cumulative
30
31 echo "check ${PROF/.prof/}.tottime, ${PROF/.prof/}.calls, and ${PROF/.prof/}.cumulative"