comparison 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
comparison
equal deleted inserted replaced
111:13dfe8214254 112:fd23ab2c1a73
1 #!/usr/bin/env python
2
3 def unescapename(name):
4 trans = {"UN":'_',"AT":'@',"SP":' ',"QN":'?',"PL":'+',"MN":'-',"TM":'*',"DV":'/',"LT":'<',"GT":'>',"NT":'!',"EQ":'=',"PR":"'"}
5 out = ''
6 while (name):
7 before,_,name = name.partition('_')
8 if name:
9 out += before[:-2]
10 key = before[-2:]
11 if key in trans:
12 out += trans[key]
13 else:
14 out += key+_
15 else:
16 out += before
17 return out.replace('__', '_')
18
19
20 names = [unescapename(line.strip()) for line in open('workernames.txt', 'r')]
21 records = []
22
23 data = open('profiler.txt', 'r')
24
25 for line in data:
26 funcid,_,rest = line[len('Func: '):].partition('\tCount: ')
27 count,_,rest = rest.partition('\tTime: ')
28 total,_,rest = rest.partition('\tAvg: ')
29 avg,_,rest = rest.partition('\tSelf: ')
30 self,_,selfavg = rest.partition('\tAvg: ')
31 records.append((names[int(funcid)], int(count), int(total), float(avg), int(self), float(selfavg)))
32
33
34 records.sort(key=lambda el: el[3])
35
36 print 'Func\tCount\tTotal(us)\tAvg(us)\tSelf(us)\tSelf Avg(us)'
37 for record in records:
38 print '%s\t%d\t%d\t%f\t%d\t%f' % record
39
40
41