blob: eed17e02e32e9022163e429b0289771f80cc4410 [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"""
Anna Zaks40b87fc2012-07-05 20:44:02 +00009import sys
10
11if __name__ == '__main__':
12 if len(sys.argv) < 2:
Valeriy Savchenkoc98872e2020-05-14 13:31:01 +030013 print('Usage: ', sys.argv[0],
14 'scan_build_output_file', file=sys.stderr)
Anna Zaks40b87fc2012-07-05 20:44:02 +000015 sys.exit(-1)
16
17 f = open(sys.argv[1], 'r')
Valeriy Savchenko475d1202020-05-22 12:51:25 +030018 time = 0.0
19 total_time = 0.0
20 max_time = 0.0
21 warnings = 0
22 count = 0
23 functions_analyzed = 0
24 reachable_blocks = 0
25 reached_max_steps = 0
26 num_steps = 0
27 num_inlined_call_sites = 0
28 num_bifurcated_call_sites = 0
29 max_cfg_size = 0
30
Anna Zaks40b87fc2012-07-05 20:44:02 +000031 for line in f:
Valeriy Savchenko475d1202020-05-22 12:51:25 +030032 if "Analyzer total time" in line:
George Karpenkova8076602017-10-02 17:59:12 +000033 s = line.split()
Valeriy Savchenko475d1202020-05-22 12:51:25 +030034 time = time + float(s[6])
35 count = count + 1
36 if float(s[6]) > max_time:
37 max_time = float(s[6])
38 if "warning generated." in line or "warnings generated" in line:
George Karpenkova8076602017-10-02 17:59:12 +000039 s = line.split()
Valeriy Savchenko475d1202020-05-22 12:51:25 +030040 warnings = warnings + int(s[0])
George Karpenkova8076602017-10-02 17:59:12 +000041 if "The # of functions analysed (as top level)" in line:
42 s = line.split()
Valeriy Savchenko475d1202020-05-22 12:51:25 +030043 functions_analyzed = functions_analyzed + int(s[0])
George Karpenkova8076602017-10-02 17:59:12 +000044 if "The % of reachable basic blocks" in line:
45 s = line.split()
Valeriy Savchenko475d1202020-05-22 12:51:25 +030046 reachable_blocks = reachable_blocks + int(s[0])
George Karpenkova8076602017-10-02 17:59:12 +000047 if "The # of times we reached the max number of steps" in line:
48 s = line.split()
Valeriy Savchenko475d1202020-05-22 12:51:25 +030049 reached_max_steps = reached_max_steps + int(s[0])
George Karpenkova8076602017-10-02 17:59:12 +000050 if "The maximum number of basic blocks in a function" in line:
51 s = line.split()
Valeriy Savchenko475d1202020-05-22 12:51:25 +030052 if max_cfg_size < int(s[0]):
53 max_cfg_size = int(s[0])
George Karpenkova8076602017-10-02 17:59:12 +000054 if "The # of steps executed" in line:
55 s = line.split()
Valeriy Savchenko475d1202020-05-22 12:51:25 +030056 num_steps = num_steps + int(s[0])
George Karpenkova8076602017-10-02 17:59:12 +000057 if "The # of times we inlined a call" in line:
58 s = line.split()
Valeriy Savchenko475d1202020-05-22 12:51:25 +030059 num_inlined_call_sites = num_inlined_call_sites + int(s[0])
George Karpenkova8076602017-10-02 17:59:12 +000060 if "The # of times we split the path due \
61 to imprecise dynamic dispatch info" in line:
62 s = line.split()
Valeriy Savchenko475d1202020-05-22 12:51:25 +030063 num_bifurcated_call_sites = num_bifurcated_call_sites + int(s[0])
George Karpenkova8076602017-10-02 17:59:12 +000064 if ") Total" in line:
65 s = line.split()
Valeriy Savchenko475d1202020-05-22 12:51:25 +030066 total_time = total_time + float(s[6])
Ted Kremenek3a0678e2015-09-08 03:50:52 +000067
Valeriy Savchenko475d1202020-05-22 12:51:25 +030068 print(f"TU count {count}")
69 print(f"Time {time}")
70 print(f"Warnings {warnings}")
71 print(f"Functions analyzed {functions_analyzed}")
72 print(f"Reachable blocks {reachable_blocks}")
73 print(f"Reached max steps {reached_max_steps}")
74 print(f"Number of steps {num_steps}")
75 print(f"Number of inlined calls {num_inlined_call_sites} "
76 f"(bifurcated {num_bifurcated_call_sites})")
77 print(f"Max time {max_time}")
78 print(f"Total time {total_time}")
79 print(f"Max CFG Size {max_cfg_size}")