Skip to content

Commit 8854145

Browse files
committed
[hotfix] harness: fix single run case
PullRequest: graalpython/294
2 parents daee77a + fae2188 commit 8854145

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

graalpython/benchmarks/src/harness.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -288,25 +288,32 @@ def run(self):
288288
print(_HRULE)
289289
print("### teardown ... ")
290290
self._call_attr(ATTR_TEARDOWN)
291-
warmup_iter = self.warmup if self.warmup > 0 else detect_warmup(durations)
292-
# if we cannot detect a warmup starting point but we performed some pre runs, we take a starting point
293-
# after the 10% of the first runs ...
294-
if warmup_iter < 0 and self.warmup_runs > 0:
295-
print("### warmup could not be detected, but %s pre-runs were executed.\n"
296-
"### we assume the benchmark is warmed up and pick an iteration "
297-
"in the first 10%% of the runs" % self.warmup_runs)
298-
warmup_iter = first_n_percent_runs(durations, 0.1)
299291
print("### benchmark complete")
300292
print(_HRULE)
301-
print("### BEST duration: %.3f s" % min(durations))
302-
print("### WORST duration: %.3f s" % max(durations))
303-
print("### AVG (all runs) duration: %.3f s" % (sum(durations) / len(durations)))
304-
if warmup_iter > 0:
305-
print("### WARMUP %s at iteration: %d" % ("specified" if self.warmup > 0 else "detected", warmup_iter))
306-
no_warmup_durations = durations[warmup_iter:]
307-
print("### AVG (no warmup) duration: %.3f s" % (sum(no_warmup_durations) / len(no_warmup_durations)))
293+
294+
# summary
295+
if self._run_once:
296+
print("### SINGLE RUN duration: %.3f s" % durations[0])
308297
else:
309-
print("### WARMUP iteration not specified or could not be detected")
298+
print("### BEST duration: %.3f s" % min(durations))
299+
print("### WORST duration: %.3f s" % max(durations))
300+
print("### AVG (all runs) duration: %.3f s" % (sum(durations) / len(durations)))
301+
warmup_iter = self.warmup if self.warmup > 0 else detect_warmup(durations)
302+
# if we cannot detect a warmup starting point but we performed some pre runs, we take a starting point
303+
# after the 10% of the first runs ...
304+
if warmup_iter < 0 and self.warmup_runs > 0:
305+
print("### warmup could not be detected, but %s pre-runs were executed.\n"
306+
"### we assume the benchmark is warmed up and pick an iteration "
307+
"in the first 10%% of the runs" % self.warmup_runs)
308+
warmup_iter = first_n_percent_runs(durations, 0.1)
309+
310+
if warmup_iter > 0:
311+
print("### WARMUP %s at iteration: %d" % ("specified" if self.warmup > 0 else "detected", warmup_iter))
312+
no_warmup_durations = durations[warmup_iter:]
313+
print("### AVG (no warmup) duration: %.3f s" % (sum(no_warmup_durations) / len(no_warmup_durations)))
314+
else:
315+
print("### WARMUP iteration not specified or could not be detected")
316+
310317
print(_HRULE)
311318
print("### RAW DURATIONS: %s" % str(durations))
312319
print(_HRULE)

0 commit comments

Comments
 (0)