4 The output from the profiler has names that end in 'names' and 'paths'.
5 This script expects you run c++filt on the 'names' file and save
6 it will the same prefix, but with 'nice_names' on the end.
7 This will be improved on the release of simple profiler.
9 The output file from this script has the same prefix as the input
10 files, but ends in 'calltree'. This file can be fed directly into
18 print "usage: ",sys.argv[0],
" prefix_of_run_data tick_cutoff n|o"
22 cutoff = int(sys.argv[2])
26 newold_flag = sys.argv[3]
28 outfile = open(prefix+
"calltree",
"w")
29 pathfile = open(prefix+
"paths",
"r")
36 for i
in l: x +=
"%d "%i
43 me.ticks_as_parent = 0
45 me.ticks_as_parent_recur = 0
50 me.ticks_as_parent += int(count)
54 me.ticks_as_parent += c
55 me.ticks_as_child += c
58 me.ticks_as_parent_recur += int(count)
61 me.children[child_id]=0
64 return "(%d,%s,%d,%d,%s)"%(me.fid,me.name,me.ticks_as_parent,me.ticks_as_child,
tostring(me.children.keys()))
76 if newold_flag ==
'o':
77 namefile = open(prefix+
"nice_names",
"r")
78 for entry
in namefile:
79 front=entry.split(
' ',2)
80 back=front[2].rsplit(
' ',16)
82 name=name.replace(
' ',
'-')
85 names[int(front[0])] =
Node(front[0],name)
87 namefile = csv.reader(open(prefix+
"nice_names",
"rb"),delimiter=
'\t')
89 names[int(row[0])] =
Node(row[0],row[-1])
92 print >>outfile,
"events: ticks"
94 for entry
in names.values():
95 print >>outfile,
"fn=(%s) %s"%(entry.fid,entry.name)
121 if ticks < cutoff:
continue
123 names[last].childTicks(ticks)
125 for i
in range(2,l-1):
126 edge = (int(all[i]), int(all[i+1]))
127 node = names[edge[0]]
128 node.recurTicks(ticks)
130 node.parentTicks(ticks)
131 node.addChild(edge[1])
132 edges.setdefault(edge,
EdgeCount()).addTicks(ticks)
137 for node
in names.values():
140 cost = node.ticks_as_child
141 print >>outfile,
"fn=(%d)"%node.fid
142 print >>outfile,
"0 %d"%cost
145 for child
in node.children.keys():
146 count = edges[(node.fid,child)].count
147 print >>outfile,
"cfn=(%d)"%child
148 print >>outfile,
"calls=%d 0"%count
149 print >>outfile,
"0 %d"%count
151 print >>outfile,
"\n\n"