-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from ESMCI/jgfouca/advanced_profiling_tool
New tool 'advanced-py-prof'
- Loading branch information
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "$@" |