From e3094b18d4fc1b5f8e5e7ca146318e501a7a4ff9 Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 5 Jan 2018 11:53:52 +0100 Subject: Firmware directory reorganization --- fw/tools/profile.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 fw/tools/profile.sh (limited to 'fw/tools/profile.sh') diff --git a/fw/tools/profile.sh b/fw/tools/profile.sh new file mode 100644 index 0000000..b209a14 --- /dev/null +++ b/fw/tools/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") + -- cgit