blob: 4ef1ceb4cec5f8ae0d3f26b5f411b242752ab515 [file] [log] [blame]
Anna Zaks84c1f4b2012-07-05 20:44:02 +00001#!/usr/bin/env python
2
3"""
4Script to Summarize statistics in the scan-build output.
5
6Statistics are enabled by passing '-internal-stats' option to scan-build
7(or '-analyzer-stats' to the analyzer).
8
9"""
10
11import string
12from operator import itemgetter
13import sys
14
15if __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 Zaks210f5a22012-08-27 18:38:32 +000031 NumInlinedCallSites = 0
32 NumBifurcatedCallSites = 0
Anna Zaks84c1f4b2012-07-05 20:44:02 +000033 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 Zaks210f5a22012-08-27 18:38:32 +000044 if ((("warning generated." in line) or ("warnings generated" in line)) and Mode == 1) :
Anna Zaks84c1f4b2012-07-05 20:44:02 +000045 s = line.split()
46 Warnings = Warnings + int(s[0])
Anna Zaks210f5a22012-08-27 18:38:32 +000047 if (("The # of functions analysed (as top level)" in line) and (Mode == 1)) :
Anna Zaks84c1f4b2012-07-05 20:44:02 +000048 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 Zaks210f5a22012-08-27 18:38:32 +000053 if (("The # of times we reached the max number of steps" in line) and (Mode == 1)) :
Anna Zaks84c1f4b2012-07-05 20:44:02 +000054 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 Zaks210f5a22012-08-27 18:38:32 +000060 if (("The # of steps executed" in line) and (Mode == 1)) :
Anna Zaks84c1f4b2012-07-05 20:44:02 +000061 s = line.split()
62 NumSteps = NumSteps + int(s[0])
Anna Zaks210f5a22012-08-27 18:38:32 +000063 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 Zaks84c1f4b2012-07-05 20:44:02 +000069 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 Zaks210f5a22012-08-27 18:38:32 +000080 print "Number of Inlined calls %d (bifurcated %d)" % (NumInlinedCallSites, NumBifurcatedCallSites)
Anna Zaks84c1f4b2012-07-05 20:44:02 +000081 print "MaxTime %f" % (MaxTime)
82 print "TotalTime %f" % (TotalTime)
83 print "Max CFG Size %d" % (MaxCFGSize)
84