diff options
author | jaseg <git@jaseg.net> | 2017-08-22 20:13:10 +0200 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2017-08-22 20:13:10 +0200 |
commit | e9f79a2e999502b86c733115d31729fbd435cbf2 (patch) | |
tree | cace2b1f6b75ff76ff3ac754e01234c82eeca418 /fw | |
parent | a18b197ac4c26a6454ed16e4727327f545a45d10 (diff) | |
download | 7seg-e9f79a2e999502b86c733115d31729fbd435cbf2.tar.gz 7seg-e9f79a2e999502b86c733115d31729fbd435cbf2.tar.bz2 7seg-e9f79a2e999502b86c733115d31729fbd435cbf2.zip |
Add profiling script
Diffstat (limited to 'fw')
-rw-r--r-- | fw/profile.gdb | 5 | ||||
-rw-r--r-- | fw/profile.sh | 26 |
2 files changed, 31 insertions, 0 deletions
diff --git a/fw/profile.gdb b/fw/profile.gdb new file mode 100644 index 0000000..fd26540 --- /dev/null +++ b/fw/profile.gdb @@ -0,0 +1,5 @@ +set pagination off +target remote localhost:3333 +while(1) + continue +end diff --git a/fw/profile.sh b/fw/profile.sh new file mode 100644 index 0000000..b209a14 --- /dev/null +++ b/fw/profile.sh @@ -0,0 +1,26 @@ +#!/bin/sh +NLOOPS=1000 +SLEEP=0.1 + +[ $# -lt 1 ] && echo "ERROR: Not enough arguments" && exit 2 +elffile="$1" + +trap "exit" SIGINT + +logfile=$(mktemp) + +arm-none-eabi-gdb -x profile.gdb "$elffile" > "$logfile" 2>/dev/null& +gdbpid=$! +trap "kill -TERM $gdbpid; rm $logfile" EXIT +echo "Gathering..." +for i in $(seq 1 $NLOOPS); do + echo "$i/$NLOOPS" + kill -INT $gdbpid + sleep $SLEEP +done +kill -TERM $gdbpid +trap "rm '$logfile'" EXIT + +egrep -o '\w+ \(.*\) at .*' "$logfile" |cut -d' ' -f1|sort|uniq -c|sort -n +echo 'Total:' $(egrep -c '\w+ \(.*\) at .*' "$logfile") + |