|
6 | 6 | parser = argparse.ArgumentParser(description="Analyze benchmark JSON data.") |
7 | 7 | parser.add_argument("--json", type=Path, default=Path("client_ivc_bench.json"), help="Benchmark JSON file name.") |
8 | 8 | parser.add_argument("--benchmark", type=str, default="ClientIVCBench/Full/6", help="Benchmark name to analyze.") |
9 | | -parser.add_argument("--prefix", type=Path, default=Path("build"), help="Prefix path for benchmark files.") |
| 9 | +parser.add_argument("--prefix", type=Path, default=Path("build-op-count-time"), help="Prefix path for benchmark files.") |
10 | 10 | args = parser.parse_args() |
11 | 11 |
|
12 | 12 | IVC_BENCH_JSON = args.json |
|
30 | 30 |
|
31 | 31 | with open(PREFIX / IVC_BENCH_JSON, "r") as read_file: |
32 | 32 | read_result = json.load(read_file) |
33 | | - for _bench in read_result.get("benchmarks", [read_result]): |
34 | | - if BENCHMARK == "" or _bench["name"] == BENCHMARK: |
| 33 | + for _bench in read_result["benchmarks"]: |
| 34 | + if _bench["name"] == BENCHMARK or BENCHMARK == "": |
35 | 35 | bench = _bench |
36 | 36 |
|
37 | 37 | bench_components = dict(filter(lambda x: x[0] in to_keep, bench.items())) |
|
51 | 51 | time_ms = bench[key] / 1e6 |
52 | 52 | print(f"{key:<{max_label_length}}{time_ms:>8.0f} {time_ms/sum_of_kept_times_ms:>8.2%}") |
53 | 53 |
|
54 | | -# There may not be "real_time" if this is from bb cli. |
55 | | -if "real_time" in bench: |
56 | | - # Validate that kept times account for most of the total measured time. |
57 | | - total_time_ms = bench["real_time"] |
58 | | - totals = '\nTotal time accounted for: {:.0f}ms/{:.0f}ms = {:.2%}' |
59 | | - totals = totals.format( |
60 | | - sum_of_kept_times_ms, total_time_ms, sum_of_kept_times_ms/total_time_ms) |
61 | | - print(totals) |
| 54 | +# Validate that kept times account for most of the total measured time. |
| 55 | +total_time_ms = bench["real_time"] |
| 56 | +totals = '\nTotal time accounted for: {:.0f}ms/{:.0f}ms = {:.2%}' |
| 57 | +totals = totals.format( |
| 58 | + sum_of_kept_times_ms, total_time_ms, sum_of_kept_times_ms/total_time_ms) |
| 59 | +print(totals) |
62 | 60 |
|
63 | 61 | print("\nMajor contributors:") |
64 | 62 | print( |
@@ -93,7 +91,7 @@ def print_contributions(prefix, ivc_bench_json, bench_name, components): |
93 | 91 | try: |
94 | 92 | with open(prefix / ivc_bench_json, "r") as read_file: |
95 | 93 | read_result = json.load(read_file) |
96 | | - bench = next((_bench for _bench in read_result.get("benchmarks", [read_result]) if bench_name == "" or _bench["name"] == bench_name), None) |
| 94 | + bench = next((_bench for _bench in read_result["benchmarks"] if _bench["name"] == bench_name or bench_name == ""), None) |
97 | 95 | if not bench: |
98 | 96 | raise ValueError(f"Benchmark '{bench_name}' not found in the JSON file.") |
99 | 97 | except FileNotFoundError: |
|
0 commit comments