From 99f3d35261e84cd876154537a0ff4d33b45df3b8 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Thu, 28 Jul 2016 16:16:17 -0600 Subject: [PATCH 1/2] New tool 'advanced-py-prof' Allows for creation of callgraph dotgraph profiles. --- scripts/Tools/advanced-py-prof | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 scripts/Tools/advanced-py-prof diff --git a/scripts/Tools/advanced-py-prof b/scripts/Tools/advanced-py-prof new file mode 100755 index 000000000000..d23502f472f1 --- /dev/null +++ b/scripts/Tools/advanced-py-prof @@ -0,0 +1,10 @@ +#! /bin/bash -e + +# Usage: advanced-py-prof +# 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 +dot -Teps ${FILE_BASENAME}.dot -o ${FILE_BASENAME}.eps From 20c2e2278d697a94e1321eb23d71c7e18a802455 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Fri, 29 Jul 2016 11:34:53 -0600 Subject: [PATCH 2/2] Make prof tools a bit more user friendly --- scripts/Tools/advanced-py-prof | 10 +++++++--- scripts/Tools/simple-py-prof | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/Tools/advanced-py-prof b/scripts/Tools/advanced-py-prof index d23502f472f1..5aecf8397107 100755 --- a/scripts/Tools/advanced-py-prof +++ b/scripts/Tools/advanced-py-prof @@ -1,10 +1,14 @@ #! /bin/bash -e -# Usage: advanced-py-prof +if [ "$#" -eq 0 ]; then + echo "Usage: advanced-py-prof " + 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 -dot -Teps ${FILE_BASENAME}.dot -o ${FILE_BASENAME}.eps +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; } diff --git a/scripts/Tools/simple-py-prof b/scripts/Tools/simple-py-prof index f904521e397d..b51e6d2ec53c 100755 --- a/scripts/Tools/simple-py-prof +++ b/scripts/Tools/simple-py-prof @@ -1,5 +1,8 @@ #! /bin/bash -# Usage: simple-py-prof +if [ "$#" -eq 0 ]; then + echo "Usage: simple-py-prof " + exit 0 +fi python -m cProfile -s time "$@"