Skip to content

Commit 300d6c2

Browse files
authored
test_benchmark.py: Fix reporting of relative performance (#26299)
Because baseline was always being set the current test we were never reports relative numbers. This fix updates the baseline only after reporting the current results.
1 parent a31ead8 commit 300d6c2

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

test/test_benchmark.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def display(self, baseline=None):
113113
final = mean / mean_baseline
114114
print(' Relative: %.2f X slower' % final)
115115
else:
116-
print()
116+
print(' Relative: No baseline recorded yet')
117117

118118
# size
119119

@@ -455,13 +455,16 @@ def do_benchmark(self, name, src, expected_output='FAIL', args=None,
455455
if not b.run:
456456
# If we won't run the benchmark, we don't need repetitions.
457457
reps = 0
458-
baseline = b
459458
print('Running benchmarker: %s: %s' % (b.__class__.__name__, b.name))
460459
b.build(self, filename, shared_args, emcc_args, native_args, native_exec, lib_builder)
461460
b.bench(args, output_parser, reps, expected_output)
462461
recorded_stats = b.display(baseline)
463462
if recorded_stats:
464463
self.add_stats(name, recorded_stats)
464+
if not baseline:
465+
# Use the first benchmarker as the baseline. Other benchmarkers can then
466+
# report relative performance compared to this.
467+
baseline = b
465468

466469
def add_stats(self, name, stats):
467470
self.stats.append({

0 commit comments

Comments
 (0)