Skip to content

Commit

Permalink
Profiler: computing stack top distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kirienko authored and LorenzMeier committed Jan 21, 2015
1 parent 647163d commit 543cb23
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Debug/poor-mans-profiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,20 @@ 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()
if line:
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 = ''
Expand All @@ -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
Expand Down

0 comments on commit 543cb23

Please sign in to comment.