Create a FlameGraph to visualize where your code is spending its time.
Requires plop and FlameGraph.
Create a FlameGraph to visualize where your code is spending its time.
Requires plop and FlameGraph.
| cat profile.out | /path/to/FlameGraph/stackcollapse.pl | /path/to/FlameGraph/flamegraph.pl > profile.big.svg |
| def print_stacks(stack_counts, outfile): | |
| with open(outfile, 'w') as op: | |
| for (stack, count) in stack_counts.iteritems(): | |
| for frame in stack: | |
| path = '/'.join(frame[0].split('/')[-2:]) | |
| loc = frame[1] | |
| fn = frame[2] | |
| print >>op, "%s:%i:%s" % (path, loc, fn) | |
| print >>op, "%i\n" % count | |
| import plop.collector | |
| collector = plop.collector.Collector() | |
| collector.start(duration=6000.) | |
| # <... my code ...> | |
| collector.stop() | |
| print_stacks(collector.stack_counts, 'profile.out') |