blob: 50e1cb854f4eaa1a3ac14f5c524ff838282e927f [file] [log] [blame]
Anna Zaks40b87fc2012-07-05 20:44:02 +00001#!/usr/bin/env python
2
3"""
4Script to Summarize statistics in the scan-build output.
5
Ted Kremenek3a0678e2015-09-08 03:50:52 +00006Statistics are enabled by passing '-internal-stats' option to scan-build
Anna Zaks40b87fc2012-07-05 20:44:02 +00007(or '-analyzer-stats' to the analyzer).
Anna Zaks40b87fc2012-07-05 20:44:02 +00008"""
9
Anna Zaks40b87fc2012-07-05 20:44:02 +000010import sys
11
12if __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 Zaks7d2babc2012-08-27 18:38:32 +000028 NumInlinedCallSites = 0
29 NumBifurcatedCallSites = 0
Anna Zaks40b87fc2012-07-05 20:44:02 +000030 MaxCFGSize = 0
Anna Zaks40b87fc2012-07-05 20:44:02 +000031 for line in f:
George Karpenkova8076602017-10-02 17:59:12 +000032 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 Kremenek3a0678e2015-09-08 03:50:52 +000067
Anna Zaks40b87fc2012-07-05 20:44:02 +000068 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 Karpenkova8076602017-10-02 17:59:12 +000075 print "Number of Inlined calls %d (bifurcated %d)" % (
76 NumInlinedCallSites, NumBifurcatedCallSites)
Anna Zaks40b87fc2012-07-05 20:44:02 +000077 print "MaxTime %f" % (MaxTime)
78 print "TotalTime %f" % (TotalTime)
79 print "Max CFG Size %d" % (MaxCFGSize)