SumTimerInfo.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/usr/bin/env python
  2. """
  3. Script to Summarize statistics in the scan-build output.
  4. Statistics are enabled by passing '-internal-stats' option to scan-build
  5. (or '-analyzer-stats' to the analyzer).
  6. """
  7. import string
  8. from operator import itemgetter
  9. import sys
  10. if __name__ == '__main__':
  11. if len(sys.argv) < 2:
  12. print >> sys.stderr, 'Usage: ', sys.argv[0],\
  13. 'scan_build_output_file'
  14. sys.exit(-1)
  15. f = open(sys.argv[1], 'r')
  16. Time = 0.0
  17. TotalTime = 0.0
  18. MaxTime = 0.0
  19. Warnings = 0
  20. Count = 0
  21. FunctionsAnalyzed = 0
  22. ReachableBlocks = 0
  23. ReachedMaxSteps = 0
  24. NumSteps = 0
  25. NumInlinedCallSites = 0
  26. NumBifurcatedCallSites = 0
  27. MaxCFGSize = 0
  28. Mode = 1
  29. for line in f:
  30. if ("Miscellaneous Ungrouped Timers" in line) :
  31. Mode = 1
  32. if (("Analyzer Total Time" in line) and (Mode == 1)) :
  33. s = line.split()
  34. Time = Time + float(s[6])
  35. Count = Count + 1
  36. if (float(s[6]) > MaxTime) :
  37. MaxTime = float(s[6])
  38. if ((("warning generated." in line) or ("warnings generated" in line)) and Mode == 1) :
  39. s = line.split()
  40. Warnings = Warnings + int(s[0])
  41. if (("The # of functions analysed (as top level)" in line) and (Mode == 1)) :
  42. s = line.split()
  43. FunctionsAnalyzed = FunctionsAnalyzed + int(s[0])
  44. if (("The % of reachable basic blocks" in line) and (Mode == 1)) :
  45. s = line.split()
  46. ReachableBlocks = ReachableBlocks + int(s[0])
  47. if (("The # of times we reached the max number of steps" in line) and (Mode == 1)) :
  48. s = line.split()
  49. ReachedMaxSteps = ReachedMaxSteps + int(s[0])
  50. if (("The maximum number of basic blocks in a function" in line) and (Mode == 1)) :
  51. s = line.split()
  52. if (MaxCFGSize < int(s[0])) :
  53. MaxCFGSize = int(s[0])
  54. if (("The # of steps executed" in line) and (Mode == 1)) :
  55. s = line.split()
  56. NumSteps = NumSteps + int(s[0])
  57. if (("The # of times we inlined a call" in line) and (Mode == 1)) :
  58. s = line.split()
  59. NumInlinedCallSites = NumInlinedCallSites + int(s[0])
  60. if (("The # of times we split the path due to imprecise dynamic dispatch info" in line) and (Mode == 1)) :
  61. s = line.split()
  62. NumBifurcatedCallSites = NumBifurcatedCallSites + int(s[0])
  63. if ((") Total" in line) and (Mode == 1)) :
  64. s = line.split()
  65. TotalTime = TotalTime + float(s[6])
  66. print "TU Count %d" % (Count)
  67. print "Time %f" % (Time)
  68. print "Warnings %d" % (Warnings)
  69. print "Functions Analyzed %d" % (FunctionsAnalyzed)
  70. print "Reachable Blocks %d" % (ReachableBlocks)
  71. print "Reached Max Steps %d" % (ReachedMaxSteps)
  72. print "Number of Steps %d" % (NumSteps)
  73. print "Number of Inlined calls %d (bifurcated %d)" % (NumInlinedCallSites, NumBifurcatedCallSites)
  74. print "MaxTime %f" % (MaxTime)
  75. print "TotalTime %f" % (TotalTime)
  76. print "Max CFG Size %d" % (MaxCFGSize)