Mercurial > repos > rhope
diff procprofile.py @ 112:fd23ab2c1a73
Small changes to make profile data a little cleaner
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 11 Oct 2010 21:53:27 -0400 |
parents | |
children | 60906f8803ef |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/procprofile.py Mon Oct 11 21:53:27 2010 -0400 @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +def unescapename(name): + trans = {"UN":'_',"AT":'@',"SP":' ',"QN":'?',"PL":'+',"MN":'-',"TM":'*',"DV":'/',"LT":'<',"GT":'>',"NT":'!',"EQ":'=',"PR":"'"} + out = '' + while (name): + before,_,name = name.partition('_') + if name: + out += before[:-2] + key = before[-2:] + if key in trans: + out += trans[key] + else: + out += key+_ + else: + out += before + return out.replace('__', '_') + + +names = [unescapename(line.strip()) for line in open('workernames.txt', 'r')] +records = [] + +data = open('profiler.txt', 'r') + +for line in data: + funcid,_,rest = line[len('Func: '):].partition('\tCount: ') + count,_,rest = rest.partition('\tTime: ') + total,_,rest = rest.partition('\tAvg: ') + avg,_,rest = rest.partition('\tSelf: ') + self,_,selfavg = rest.partition('\tAvg: ') + records.append((names[int(funcid)], int(count), int(total), float(avg), int(self), float(selfavg))) + + +records.sort(key=lambda el: el[3]) + +print 'Func\tCount\tTotal(us)\tAvg(us)\tSelf(us)\tSelf Avg(us)' +for record in records: + print '%s\t%d\t%d\t%f\t%d\t%f' % record + + +