Skip to content

Commit 181dac7

Browse files
committed
add airspeed velocity output
1 parent d8849ba commit 181dac7

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

regtest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import test_util
2727
import test_report as report
2828
import test_coverage as coverage
29+
import test_asv
2930

3031
safe_flags = ['TEST', 'USE_CUDA', 'USE_ACC', 'USE_MPI', 'USE_OMP', 'DEBUG', 'USE_GPU']
3132

@@ -1265,6 +1266,11 @@ def test_suite(argv):
12651266
with open(file_path, 'w') as json_file:
12661267
json.dump(runtimes, json_file, indent=4)
12671268

1269+
#--------------------------------------------------------------------------
1270+
# output ASV results
1271+
#--------------------------------------------------------------------------
1272+
test_asv.save_asv_history(suite, test_list)
1273+
12681274
#--------------------------------------------------------------------------
12691275
# parameter coverage
12701276
#--------------------------------------------------------------------------

test_asv.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import json
2+
import os
3+
import platform
4+
import time
5+
6+
def save_asv_history(suite, test_list):
7+
"""
8+
Save test results in Airspeed Velocity (ASV) format.
9+
"""
10+
11+
# Get the commit hash from the source repo
12+
commit_hash = "unknown"
13+
if suite.sourceTree in suite.repos:
14+
if suite.repos[suite.sourceTree].hash_current:
15+
commit_hash = suite.repos[suite.sourceTree].hash_current.strip()
16+
17+
if commit_hash == "unknown":
18+
# Fallback: use the first repo or "source"
19+
if "source" in suite.repos and suite.repos["source"].hash_current:
20+
commit_hash = suite.repos["source"].hash_current.strip()
21+
elif len(suite.repos) > 0:
22+
# Use the first available repo hash
23+
first_repo = list(suite.repos.values())[0]
24+
if first_repo.hash_current:
25+
commit_hash = first_repo.hash_current.strip()
26+
27+
# Current timestamp in milliseconds
28+
timestamp = int(time.time() * 1000)
29+
30+
# Environment and Machine Info
31+
machine_name = platform.node()
32+
os_name = platform.system()
33+
python_version = platform.python_version()
34+
35+
params = {
36+
"machine": machine_name,
37+
"os": os_name,
38+
"python": python_version
39+
}
40+
41+
results = {}
42+
for test in test_list:
43+
# We only care about tests that passed execution and have a wall time
44+
# Use record_runtime logic but we can be slightly more permissive if needed,
45+
# but keeping it consistent with wallclock_history is good.
46+
if test.record_runtime(suite):
47+
results[test.name] = test.wall_time
48+
49+
if not results:
50+
return
51+
52+
data = {
53+
"version": 1,
54+
"commit_hash": commit_hash,
55+
"env_name": f"regtest-{machine_name}",
56+
"date": timestamp,
57+
"params": params,
58+
"results": results,
59+
"requirements": {}
60+
}
61+
62+
# Determine output path
63+
# We'll put it in a 'asv' subdirectory within the benchmarks directory
64+
try:
65+
bench_dir = suite.get_bench_dir()
66+
except SystemExit:
67+
# If get_bench_dir fails (e.g. dir doesn't exist and strict checking),
68+
# we might skip ASV saving or try to create it if allowed.
69+
# But regtest.py usually ensures bench_dir is checked.
70+
return
71+
72+
asv_dir = os.path.join(bench_dir, "asv")
73+
machine_dir = os.path.join(asv_dir, machine_name)
74+
75+
if not os.path.exists(machine_dir):
76+
try:
77+
os.makedirs(machine_dir)
78+
except OSError:
79+
suite.log.warn(f"Could not create ASV directory: {machine_dir}")
80+
return
81+
82+
output_file = os.path.join(machine_dir, f"{commit_hash}.json")
83+
84+
try:
85+
with open(output_file, 'w') as f:
86+
json.dump(data, f, indent=4)
87+
suite.log.log(f"ASV results saved to {output_file}")
88+
except Exception as e:
89+
suite.log.warn(f"Failed to save ASV results: {e}")

0 commit comments

Comments
 (0)