aboutsummaryrefslogtreecommitdiff
path: root/Debug/poor-mans-profiler.sh
diff options
context:
space:
mode:
authorPavel Kirienko <pavel.kirienko@gmail.com>2015-01-17 03:57:46 +0300
committerLorenz Meier <lm@inf.ethz.ch>2015-01-21 14:54:23 +0100
commit543cb231282fdb899557f42003f53ac2f7a7dcc7 (patch)
tree8bc5a1c08de9bcb8fbb0a8bb20b022c995d711b5 /Debug/poor-mans-profiler.sh
parent647163d6fa4761b0799e073bae8ea368a986b4fe (diff)
downloadpx4-firmware-543cb231282fdb899557f42003f53ac2f7a7dcc7.tar.gz
px4-firmware-543cb231282fdb899557f42003f53ac2f7a7dcc7.tar.bz2
px4-firmware-543cb231282fdb899557f42003f53ac2f7a7dcc7.zip
Profiler: computing stack top distribution
Diffstat (limited to 'Debug/poor-mans-profiler.sh')
-rwxr-xr-xDebug/poor-mans-profiler.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/Debug/poor-mans-profiler.sh b/Debug/poor-mans-profiler.sh
index 63dba562a..d907d8749 100755
--- a/Debug/poor-mans-profiler.sh
+++ b/Debug/poor-mans-profiler.sh
@@ -212,6 +212,9 @@ def parse(line):
stacks = collections.defaultdict(int)
current = ''
+stack_tops = collections.defaultdict(int)
+num_stack_frames = 0
+
for idx,line in enumerate(fileinput.input()):
try:
line = line.strip()
@@ -219,6 +222,10 @@ for idx,line in enumerate(fileinput.input()):
inf = parse(line)
fun = inf['function']
current = (fun + ';' + current) if current else fun
+
+ if inf['frame_num'] == 0:
+ num_stack_frames += 1
+ stack_tops[fun] += 1
elif current:
stacks[current] += 1
current = ''
@@ -227,6 +234,11 @@ for idx,line in enumerate(fileinput.input()):
for s, f in sorted(stacks.items(), key=lambda (s, f): s):
print(s, f)
+
+print('Total stack frames:', num_stack_frames, file=sys.stderr)
+print('Top consumers (distribution of the stack tops):', file=sys.stderr)
+for name,num in sorted(stack_tops.items(), key=lambda (name, num): num, reverse=True)[:10]:
+ print('% 5.1f%% ' % (100 * num / num_stack_frames), name, file=sys.stderr)
EOF
cat $stacksfile | python /tmp/pmpn-folder.py > $foldfile