display_callgraph.py 979 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/python
  2. import cPickle
  3. data = cPickle.load(open("callgraph.pkl"))
  4. # data = data['modItems']
  5. callgraph = data['callgraph']
  6. closure = data['closure']
  7. sccs = data['sccs']
  8. fn_bottle, call_bottle = data['bottlenecks']
  9. for n_reachable, fn in sorted(list((len(r), fn) for fn, r in closure.iteritems())):
  10. print "%s can reach %s other functions." %(fn, n_reachable)
  11. c = [ (len(component), component) for component in sccs ]
  12. c.sort()
  13. print "\n================================"
  14. for n, component in c:
  15. if n < 2:
  16. continue
  17. print "Strongly connected component of size %d:"%n
  18. print component
  19. print "\n================================"
  20. print "====== Number of functions pulled into blob, by function in blob."
  21. fn_bottle.sort()
  22. for n, fn in fn_bottle[-30:]:
  23. print "%3d: %s"%(n, fn)
  24. print "====== Number of functions pulled into blob, by call in blob."
  25. call_bottle.sort()
  26. for n, fn1, _, fn2 in call_bottle[-30:]:
  27. print "%3d: %s -> %s "%(n, fn2, fn1)