From 816332cbaf256c405a109d8cc16fec8f15df907e Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Thu, 21 May 2026 19:04:01 +1000 Subject: Added benchmarking to the CI (#423) * Added benchmarking to the CI * Updated writing access of benchmark.yml * Added benchmark-comment.yml that pushes the comment to the PR * Added read permission --- .github/scripts/update_history.py | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/scripts/update_history.py (limited to '.github/scripts/update_history.py') diff --git a/.github/scripts/update_history.py b/.github/scripts/update_history.py new file mode 100644 index 00000000..6fae798c --- /dev/null +++ b/.github/scripts/update_history.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +""" +Append the current JMH results to benchmark-history.json and overwrite +benchmark-latest.json on the benchmark-data branch working directory. + +Usage: + python update_history.py [] + + is the directory where benchmark-history.json and +benchmark-latest.json will be written (the benchmark-data checkout root). +""" + +import json +import sys +from datetime import datetime, timezone +from pathlib import Path + + +def main() -> None: + if len(sys.argv) < 4: + print("Usage: update_history.py []", file=sys.stderr) + sys.exit(1) + + results_path = Path(sys.argv[1]) + output_dir = Path(sys.argv[2]) + commit_sha = sys.argv[3] + pr_number = int(sys.argv[4]) if len(sys.argv) > 4 else None + + results = json.loads(results_path.read_text()) + + # Tag each result entry with the commit so compare_benchmarks.py can display it + for entry in results: + entry["_meta_commit"] = commit_sha + + history_path = output_dir / "benchmark-history.json" + history = json.loads(history_path.read_text()) if history_path.exists() else [] + + history.append( + { + "commit": commit_sha, + "pr": pr_number, + "timestamp": datetime.now(timezone.utc).isoformat(), + "results": results, + } + ) + + history_path.write_text(json.dumps(history, indent=2)) + + print(f"Stored results for commit {commit_sha[:7]} ({len(results)} benchmark(s)).") + + +if __name__ == "__main__": + main() \ No newline at end of file -- cgit v1.2.3