Anna Zaks | 40b87fc | 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 | |
Ted Kremenek | 3a0678e | 2015-09-08 03:50:52 +0000 | [diff] [blame] | 6 | Statistics are enabled by passing '-internal-stats' option to scan-build |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 7 | (or '-analyzer-stats' to the analyzer). |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 8 | """ |
| 9 | |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 10 | import sys |
| 11 | |
| 12 | if __name__ == '__main__': |
| 13 | if len(sys.argv) < 2: |
| 14 | print >> sys.stderr, 'Usage: ', sys.argv[0],\ |
| 15 | 'scan_build_output_file' |
| 16 | sys.exit(-1) |
| 17 | |
| 18 | f = open(sys.argv[1], 'r') |
| 19 | Time = 0.0 |
| 20 | TotalTime = 0.0 |
| 21 | MaxTime = 0.0 |
| 22 | Warnings = 0 |
| 23 | Count = 0 |
| 24 | FunctionsAnalyzed = 0 |
| 25 | ReachableBlocks = 0 |
| 26 | ReachedMaxSteps = 0 |
| 27 | NumSteps = 0 |
Anna Zaks | 7d2babc | 2012-08-27 18:38:32 +0000 | [diff] [blame] | 28 | NumInlinedCallSites = 0 |
| 29 | NumBifurcatedCallSites = 0 |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 30 | MaxCFGSize = 0 |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 31 | for line in f: |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 32 | if ("Analyzer Total Time" in line): |
| 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): |
| 39 | s = line.split() |
| 40 | Warnings = Warnings + int(s[0]) |
| 41 | if "The # of functions analysed (as top level)" in line: |
| 42 | s = line.split() |
| 43 | FunctionsAnalyzed = FunctionsAnalyzed + int(s[0]) |
| 44 | if "The % of reachable basic blocks" in line: |
| 45 | s = line.split() |
| 46 | ReachableBlocks = ReachableBlocks + int(s[0]) |
| 47 | if "The # of times we reached the max number of steps" in line: |
| 48 | s = line.split() |
| 49 | ReachedMaxSteps = ReachedMaxSteps + int(s[0]) |
| 50 | if "The maximum number of basic blocks in a function" in line: |
| 51 | s = line.split() |
| 52 | if MaxCFGSize < int(s[0]): |
| 53 | MaxCFGSize = int(s[0]) |
| 54 | if "The # of steps executed" in line: |
| 55 | s = line.split() |
| 56 | NumSteps = NumSteps + int(s[0]) |
| 57 | if "The # of times we inlined a call" in line: |
| 58 | s = line.split() |
| 59 | NumInlinedCallSites = NumInlinedCallSites + int(s[0]) |
| 60 | if "The # of times we split the path due \ |
| 61 | to imprecise dynamic dispatch info" in line: |
| 62 | s = line.split() |
| 63 | NumBifurcatedCallSites = NumBifurcatedCallSites + int(s[0]) |
| 64 | if ") Total" in line: |
| 65 | s = line.split() |
| 66 | TotalTime = TotalTime + float(s[6]) |
Ted Kremenek | 3a0678e | 2015-09-08 03:50:52 +0000 | [diff] [blame] | 67 | |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 68 | print "TU Count %d" % (Count) |
| 69 | print "Time %f" % (Time) |
| 70 | print "Warnings %d" % (Warnings) |
| 71 | print "Functions Analyzed %d" % (FunctionsAnalyzed) |
| 72 | print "Reachable Blocks %d" % (ReachableBlocks) |
| 73 | print "Reached Max Steps %d" % (ReachedMaxSteps) |
| 74 | print "Number of Steps %d" % (NumSteps) |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 75 | print "Number of Inlined calls %d (bifurcated %d)" % ( |
| 76 | NumInlinedCallSites, NumBifurcatedCallSites) |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 77 | print "MaxTime %f" % (MaxTime) |
| 78 | print "TotalTime %f" % (TotalTime) |
| 79 | print "Max CFG Size %d" % (MaxCFGSize) |