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 |
| 31 | MaxCFGSize = 0 |
| 32 | Mode = 1 |
| 33 | for line in f: |
| 34 | if ("Miscellaneous Ungrouped Timers" in line) : |
| 35 | Mode = 1 |
| 36 | if (("Analyzer Total Time" in line) and (Mode == 1)) : |
| 37 | s = line.split() |
| 38 | Time = Time + float(s[6]) |
| 39 | Count = Count + 1 |
| 40 | if (float(s[6]) > MaxTime) : |
| 41 | MaxTime = float(s[6]) |
| 42 | if ((("warning generated." in line) or ("warnings generated." in line)) and Mode == 1) : |
| 43 | s = line.split() |
| 44 | Warnings = Warnings + int(s[0]) |
| 45 | if (("The # of functions analysed (as top level)." in line) and (Mode == 1)) : |
| 46 | s = line.split() |
| 47 | FunctionsAnalyzed = FunctionsAnalyzed + int(s[0]) |
| 48 | if (("The % of reachable basic blocks" in line) and (Mode == 1)) : |
| 49 | s = line.split() |
| 50 | ReachableBlocks = ReachableBlocks + int(s[0]) |
| 51 | if (("The # of times we reached the max number of steps." in line) and (Mode == 1)) : |
| 52 | s = line.split() |
| 53 | ReachedMaxSteps = ReachedMaxSteps + int(s[0]) |
| 54 | if (("The maximum number of basic blocks in a function" in line) and (Mode == 1)) : |
| 55 | s = line.split() |
| 56 | if (MaxCFGSize < int(s[0])) : |
| 57 | MaxCFGSize = int(s[0]) |
| 58 | if (("The # of steps executed." in line) and (Mode == 1)) : |
| 59 | s = line.split() |
| 60 | NumSteps = NumSteps + int(s[0]) |
| 61 | if ((") Total" in line) and (Mode == 1)) : |
| 62 | s = line.split() |
| 63 | TotalTime = TotalTime + float(s[6]) |
| 64 | |
| 65 | print "TU Count %d" % (Count) |
| 66 | print "Time %f" % (Time) |
| 67 | print "Warnings %d" % (Warnings) |
| 68 | print "Functions Analyzed %d" % (FunctionsAnalyzed) |
| 69 | print "Reachable Blocks %d" % (ReachableBlocks) |
| 70 | print "Reached Max Steps %d" % (ReachedMaxSteps) |
| 71 | print "Number of Steps %d" % (NumSteps) |
| 72 | print "MaxTime %f" % (MaxTime) |
| 73 | print "TotalTime %f" % (TotalTime) |
| 74 | print "Max CFG Size %d" % (MaxCFGSize) |
| 75 | |