blob: 9b4323dfaf8d092418a81c295ae84a8ddf582ac2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/usr/bin/env python3
"""
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> <existing-history.json> <output.json> <commit_sha>
"""
import json
import sys
from datetime import datetime, timezone
from pathlib import Path
def main() -> None:
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])
existing_path = Path(sys.argv[2])
output_path = Path(sys.argv[3])
commit_sha = sys.argv[4]
results = json.loads(results_path.read_text())
for entry in results:
entry["_meta_commit"] = commit_sha
history = json.loads(existing_path.read_text()) if existing_path.exists() else []
history.append(
{
"commit": commit_sha,
"timestamp": datetime.now(timezone.utc).isoformat(),
"results": results,
}
)
output_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()
|