Skip to content

Commit

Permalink
Merge pull request #305 from ESMCI/jgfouca/advanced_profiling_tool
Browse files Browse the repository at this point in the history
New tool 'advanced-py-prof'
  • Loading branch information
jedwards4b authored Jul 29, 2016
2 parents 1f9b49b + 20c2e22 commit 929f05a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions scripts/Tools/advanced-py-prof
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /bin/bash -e

if [ "$#" -eq 0 ]; then
echo "Usage: advanced-py-prof <python exec and arguments>"
exit 0
fi

# Requires graphviz and gprof2dot

DATE_STAMP=$(date "+%Y-%m-%d_%H%M%S")
FILE_BASENAME=$(basename $1).${DATE_STAMP}
python -m cProfile -o ${FILE_BASENAME}.prof "$@"
gprof2dot -f pstats ${FILE_BASENAME}.prof -o ${FILE_BASENAME}.dot || { echo "This tool requires gprof2dot"; exit 1; }
dot -Teps ${FILE_BASENAME}.dot -o ${FILE_BASENAME}.eps || { echo "This tool requires graphviz (dot)"; exit 1; }
5 changes: 4 additions & 1 deletion scripts/Tools/simple-py-prof
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#! /bin/bash

# Usage: simple-py-prof <python exec and arguments>
if [ "$#" -eq 0 ]; then
echo "Usage: simple-py-prof <python exec and arguments>"
exit 0
fi

python -m cProfile -s time "$@"

0 comments on commit 929f05a

Please sign in to comment.