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 | from __future__ import absolute_import, division, print_function |
10 | |
11 | import sys |
12 | |
13 | if __name__ == '__main__': |
14 | if len(sys.argv) < 2: |
15 | print('Usage: ', sys.argv[0],\ |
16 | 'scan_build_output_file', file=sys.stderr) |
17 | sys.exit(-1) |
18 | |
19 | f = open(sys.argv[1], 'r') |
20 | Time = 0.0 |
21 | TotalTime = 0.0 |
22 | MaxTime = 0.0 |
23 | Warnings = 0 |
24 | Count = 0 |
25 | FunctionsAnalyzed = 0 |
26 | ReachableBlocks = 0 |
27 | ReachedMaxSteps = 0 |
28 | NumSteps = 0 |
29 | NumInlinedCallSites = 0 |
30 | NumBifurcatedCallSites = 0 |
31 | MaxCFGSize = 0 |
32 | for line in f: |
33 | if ("Analyzer Total Time" in line): |
34 | s = line.split() |
35 | Time = Time + float(s[6]) |
36 | Count = Count + 1 |
37 | if (float(s[6]) > MaxTime): |
38 | MaxTime = float(s[6]) |
39 | if ("warning generated." in line) or ("warnings generated" in line): |
40 | s = line.split() |
41 | Warnings = Warnings + int(s[0]) |
42 | if "The # of functions analysed (as top level)" in line: |
43 | s = line.split() |
44 | FunctionsAnalyzed = FunctionsAnalyzed + int(s[0]) |
45 | if "The % of reachable basic blocks" in line: |
46 | s = line.split() |
47 | ReachableBlocks = ReachableBlocks + int(s[0]) |
48 | if "The # of times we reached the max number of steps" in line: |
49 | s = line.split() |
50 | ReachedMaxSteps = ReachedMaxSteps + int(s[0]) |
51 | if "The maximum number of basic blocks in a function" in line: |
52 | s = line.split() |
53 | if MaxCFGSize < int(s[0]): |
54 | MaxCFGSize = int(s[0]) |
55 | if "The # of steps executed" in line: |
56 | s = line.split() |
57 | NumSteps = NumSteps + int(s[0]) |
58 | if "The # of times we inlined a call" in line: |
59 | s = line.split() |
60 | NumInlinedCallSites = NumInlinedCallSites + int(s[0]) |
61 | if "The # of times we split the path due \ |
62 | to imprecise dynamic dispatch info" in line: |
63 | s = line.split() |
64 | NumBifurcatedCallSites = NumBifurcatedCallSites + int(s[0]) |
65 | if ") Total" in line: |
66 | s = line.split() |
67 | TotalTime = TotalTime + float(s[6]) |
68 | |
69 | print("TU Count %d" % (Count)) |
70 | print("Time %f" % (Time)) |
71 | print("Warnings %d" % (Warnings)) |
72 | print("Functions Analyzed %d" % (FunctionsAnalyzed)) |
73 | print("Reachable Blocks %d" % (ReachableBlocks)) |
74 | print("Reached Max Steps %d" % (ReachedMaxSteps)) |
75 | print("Number of Steps %d" % (NumSteps)) |
76 | print("Number of Inlined calls %d (bifurcated %d)" % ( |
77 | NumInlinedCallSites, NumBifurcatedCallSites)) |
78 | print("MaxTime %f" % (MaxTime)) |
79 | print("TotalTime %f" % (TotalTime)) |
80 | print("Max CFG Size %d" % (MaxCFGSize)) |
81 | |