display_callgraph.py 952 B

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