Anna Zaks | 40b87fc | 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 | |
Ted Kremenek | 3a0678e | 2015-09-08 03:50:52 +0000 | [diff] [blame] | 6 | Statistics are enabled by passing '-internal-stats' option to scan-build |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 7 | (or '-analyzer-stats' to the analyzer). |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 8 | """ |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 9 | import sys |
| 10 | |
| 11 | if __name__ == '__main__': |
| 12 | if len(sys.argv) < 2: |
Valeriy Savchenko | c98872e | 2020-05-14 13:31:01 +0300 | [diff] [blame] | 13 | print('Usage: ', sys.argv[0], |
| 14 | 'scan_build_output_file', file=sys.stderr) |
Anna Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 15 | sys.exit(-1) |
| 16 | |
| 17 | f = open(sys.argv[1], 'r') |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 18 | 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 Zaks | 40b87fc | 2012-07-05 20:44:02 +0000 | [diff] [blame] | 31 | for line in f: |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 32 | if "Analyzer total time" in line: |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 33 | s = line.split() |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 34 | 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 Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 39 | s = line.split() |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 40 | warnings = warnings + int(s[0]) |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 41 | if "The # of functions analysed (as top level)" in line: |
| 42 | s = line.split() |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 43 | functions_analyzed = functions_analyzed + int(s[0]) |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 44 | if "The % of reachable basic blocks" in line: |
| 45 | s = line.split() |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 46 | reachable_blocks = reachable_blocks + int(s[0]) |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 47 | if "The # of times we reached the max number of steps" in line: |
| 48 | s = line.split() |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 49 | reached_max_steps = reached_max_steps + int(s[0]) |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 50 | if "The maximum number of basic blocks in a function" in line: |
| 51 | s = line.split() |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 52 | if max_cfg_size < int(s[0]): |
| 53 | max_cfg_size = int(s[0]) |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 54 | if "The # of steps executed" in line: |
| 55 | s = line.split() |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 56 | num_steps = num_steps + int(s[0]) |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 57 | if "The # of times we inlined a call" in line: |
| 58 | s = line.split() |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 59 | num_inlined_call_sites = num_inlined_call_sites + int(s[0]) |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 60 | if "The # of times we split the path due \ |
| 61 | to imprecise dynamic dispatch info" in line: |
| 62 | s = line.split() |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 63 | num_bifurcated_call_sites = num_bifurcated_call_sites + int(s[0]) |
George Karpenkov | a807660 | 2017-10-02 17:59:12 +0000 | [diff] [blame] | 64 | if ") Total" in line: |
| 65 | s = line.split() |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 66 | total_time = total_time + float(s[6]) |
Ted Kremenek | 3a0678e | 2015-09-08 03:50:52 +0000 | [diff] [blame] | 67 | |
Valeriy Savchenko | 475d120 | 2020-05-22 12:51:25 +0300 | [diff] [blame] | 68 | 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}") |