Merge branch 'maint-0.2.8' into release-0.2.8
[tor.git] / scripts / maint / display_callgraph.py
blobc9001c6d968e866efeb92165264f32bdd92ec53b
1 #!/usr/bin/python
3 import cPickle
5 data = cPickle.load(open("callgraph.pkl"))
7 # data = data['modItems']
9 callgraph = data['callgraph']
10 closure = data['closure']
11 sccs = data['sccs']
12 fn_bottle, call_bottle = data['bottlenecks']
14 for n_reachable, fn in sorted(list((len(r), fn) for fn, r in closure.iteritems())):
15 print "%s can reach %s other functions." %(fn, n_reachable)
18 c = [ (len(component), component) for component in sccs ]
19 c.sort()
21 print "\n================================"
23 for n, component in c:
24 if n < 2:
25 continue
26 print "Strongly connected component of size %d:"%n
27 print component
30 print "\n================================"
32 print "====== Number of functions pulled into blob, by function in blob."
33 fn_bottle.sort()
34 for n, fn in fn_bottle[-30:]:
35 print "%3d: %s"%(n, fn)
37 print "====== Number of functions pulled into blob, by call in blob."
38 call_bottle.sort()
39 for n, fn1, _, fn2 in call_bottle[-30:]:
40 print "%3d: %s -> %s "%(n, fn2, fn1)