Skip to content

Commit 72296b3

Browse files
fixup
1 parent 9cb9bb5 commit 72296b3

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

devops/scripts/benchmarks/main.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ def run_iterations(
9999
failures: dict[str, str],
100100
run_trace: TracingType = TracingType.NONE,
101101
force_trace: bool = False,
102-
):
102+
) -> bool:
103+
"""
104+
Returns True if all iterations completed successfully, False otherwise.
105+
Unless options.exit_on_failure is set, then exception is raised.
106+
"""
107+
103108
for iter in range(iters):
104109
log.info(f"running {benchmark.name()}, iteration {iter}... ")
105110
try:
@@ -111,7 +116,7 @@ def run_iterations(
111116
raise RuntimeError(f"Benchmark produced no results!")
112117
else:
113118
failures[benchmark.name()] = "benchmark produced no results!"
114-
break
119+
return False
115120

116121
for bench_result in bench_results:
117122
log.info(
@@ -132,10 +137,15 @@ def run_iterations(
132137
f"Benchmark failed: {failure_label} verification failed: {str(e)}"
133138
)
134139
else:
135-
failures[failure_label] = f"verification failed: {str(e)}"
136-
log.error(f"complete ({failure_label}: verification failed: {str(e)}).")
140+
failures[failure_label] = (
141+
f"{failure_label}: verification failed: {str(e)}"
142+
)
143+
log.error(f"{failure_label}: verification failed: {str(e)}.")
137144
continue
138145

146+
# Iterations completed successfully
147+
return True
148+
139149

140150
# https://www.statology.org/modified-z-score/
141151
def modified_z_score(values: list[float]) -> list[float]:
@@ -341,6 +351,7 @@ def main(directory, additional_env_vars, compare_names, filter, execution_stats)
341351
merged_env_vars = {**additional_env_vars}
342352
intermediate_results: dict[str, list[Result]] = {}
343353
processed: list[Result] = []
354+
iterations_rc = False
344355

345356
# Determine if we should run regular benchmarks
346357
# Run regular benchmarks if:
@@ -355,7 +366,7 @@ def main(directory, additional_env_vars, compare_names, filter, execution_stats)
355366

356367
if should_run_regular:
357368
for _ in range(options.iterations_stddev):
358-
run_iterations(
369+
iterations_rc = run_iterations(
359370
benchmark,
360371
merged_env_vars,
361372
options.iterations,
@@ -375,7 +386,7 @@ def main(directory, additional_env_vars, compare_names, filter, execution_stats)
375386
if options.unitrace and (
376387
benchmark.traceable(TracingType.UNITRACE) or args.unitrace == "force"
377388
):
378-
run_iterations(
389+
iterations_rc = run_iterations(
379390
benchmark,
380391
merged_env_vars,
381392
1,
@@ -389,7 +400,7 @@ def main(directory, additional_env_vars, compare_names, filter, execution_stats)
389400
benchmark.traceable(TracingType.FLAMEGRAPH)
390401
or args.flamegraph == "force"
391402
):
392-
run_iterations(
403+
iterations_rc = run_iterations(
393404
benchmark,
394405
merged_env_vars,
395406
1,
@@ -400,7 +411,10 @@ def main(directory, additional_env_vars, compare_names, filter, execution_stats)
400411
)
401412

402413
results += processed
403-
execution_stats["tests_passed"] += 1
414+
if iterations_rc:
415+
execution_stats["tests_passed"] += 1
416+
else:
417+
execution_stats["tests_failed"] += 1
404418
except Exception as e:
405419
execution_stats["tests_failed"] += 1
406420
if options.exit_on_failure:

0 commit comments

Comments
 (0)