MCPcopy Create free account
hub / github.com/Open-Quant/openquant / main

Function main

scripts/collect_bench_results.py:20–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18
19
20def main():
21 parser = argparse.ArgumentParser(description="Collect criterion benchmark means into a single JSON file")
22 parser.add_argument("--criterion-dir", default="target/criterion")
23 parser.add_argument("--out", default="benchmarks/latest_benchmarks.json")
24 parser.add_argument("--commit", default="")
25 parser.add_argument("--allow-list", default="", help="JSON file with benchmark names to include")
26 args = parser.parse_args()
27
28 criterion_dir = Path(args.criterion_dir)
29 out_path = Path(args.out)
30
31 allow = None
32 if args.allow_list:
33 allow = set(json.loads(Path(args.allow_list).read_text()))
34
35 benchmarks = {}
36 for est_path in find_estimates(criterion_dir):
37 try:
38 data = json.loads(est_path.read_text())
39 mean = data["mean"]["point_estimate"]
40 lower = data["mean"]["confidence_interval"]["lower_bound"]
41 upper = data["mean"]["confidence_interval"]["upper_bound"]
42 except Exception:
43 continue
44 name = bench_name(criterion_dir, est_path)
45 if allow is not None and name not in allow:
46 continue
47 benchmarks[name] = {
48 "mean_ns": mean,
49 "mean_ms": mean / 1_000_000.0,
50 "ci_lower_ns": lower,
51 "ci_upper_ns": upper,
52 }
53
54 payload = {
55 "generated_at_utc": datetime.now(timezone.utc).isoformat(),
56 "commit": args.commit,
57 "count": len(benchmarks),
58 "benchmarks": dict(sorted(benchmarks.items())),
59 }
60
61 out_path.parent.mkdir(parents=True, exist_ok=True)
62 out_path.write_text(json.dumps(payload, indent=2) + "\n")
63 print(f"wrote {out_path} with {len(benchmarks)} benchmarks")
64
65
66if __name__ == "__main__":

Callers 1

Calls 2

find_estimatesFunction · 0.85
bench_nameFunction · 0.85

Tested by

no test coverage detected