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