Skip to content

Commit 8a8a3ad

Browse files
committed
[benchmark] Limit setup overhead detection (>20)
For really small runtimes < 20 μs this method of setup overhead detection doesn’t work. Even 1μs change in 20μs runtime is 5%. Just return no overhead.
1 parent 8fcf884 commit 8a8a3ad

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

benchmark/scripts/Benchmark_Driver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ class BenchmarkDoctor(object):
442442
[[result.samples.min for result in i_series]
443443
for i_series in
444444
[select(measurements, num_iters=i) for i in [1, 2]]]]
445-
setup = int(round(2.0 * (ti1 - ti2)))
445+
setup = int(round(2.0 * (ti1 - ti2))) if ti2 > 20 else 0
446446
ratio = (setup / ti1) if ti1 > 0 else 0
447447
return (setup, ratio)
448448

benchmark/scripts/test_Benchmark_Driver.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,11 +728,18 @@ def test_benchmark_has_no_significant_setup_overhead(self):
728728
'SO O i2a': _PTR(min=67), 'SO O i2b': _PTR(min=68)})
729729
doctor.analyze({'name': 'Zero', 'Zero O i1a': _PTR(min=0),
730730
'Zero O i2a': _PTR(min=0)})
731+
doctor.analyze({
732+
'name': 'OOO', # Out Of Order
733+
# Impossible to detect overhead -- limits of precision:
734+
# Even 1μs change in 20μs runtime is 5%.
735+
'OOO O i1a': _PTR(min=21),
736+
'OOO O i2a': _PTR(min=20)})
731737
output = out.getvalue()
732738

733739
self.assertIn('runtime: ', output)
734740
self.assertNotIn('NoOverhead', output)
735741
self.assertNotIn('ZeroRuntime', output)
742+
self.assertNotIn('OOO', output)
736743
self.assert_contains(
737744
["'SO' has setup overhead of 4 μs (5.8%)."],
738745
self.logs['error'])

0 commit comments

Comments
 (0)