summaryrefslogtreecommitdiff
path: root/.github/scripts/update_history.py
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2026-05-21 21:44:27 +1000
committerGitHub <noreply@github.com>2026-05-21 21:44:27 +1000
commit01e809146e8f19f58faf3a808ea994107730738d (patch)
tree02e48217894b25df8bdd7d526298b58d0ef407f8 /.github/scripts/update_history.py
parent816332cbaf256c405a109d8cc16fec8f15df907e (diff)
Updated the benchmark submit to push to a release file (#425)
Diffstat (limited to '.github/scripts/update_history.py')
-rw-r--r--.github/scripts/update_history.py30
1 files changed, 13 insertions, 17 deletions
diff --git a/.github/scripts/update_history.py b/.github/scripts/update_history.py
index 6fae798c..9b4323df 100644
--- a/.github/scripts/update_history.py
+++ b/.github/scripts/update_history.py
@@ -1,13 +1,10 @@
#!/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.
+Append the current JMH results to the benchmark history and write the updated
+history to a new file.
Usage:
- python update_history.py <results.json> <output_dir> <commit_sha> [<pr_number>]
-
-<output_dir> is the directory where benchmark-history.json and
-benchmark-latest.json will be written (the benchmark-data checkout root).
+ python update_history.py <results.json> <existing-history.json> <output.json> <commit_sha>
"""
import json
@@ -17,35 +14,34 @@ from pathlib import Path
def main() -> None:
- if len(sys.argv) < 4:
- print("Usage: update_history.py <results.json> <output_dir> <commit_sha> [<pr_number>]", file=sys.stderr)
+ if len(sys.argv) < 5:
+ print(
+ "Usage: update_history.py <results.json> <existing-history.json> <output.json> <commit_sha>",
+ 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
+ existing_path = Path(sys.argv[2])
+ output_path = Path(sys.argv[3])
+ commit_sha = sys.argv[4]
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 = json.loads(existing_path.read_text()) if existing_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))
-
+ output_path.write_text(json.dumps(history, indent=2))
print(f"Stored results for commit {commit_sha[:7]} ({len(results)} benchmark(s)).")