@@ -667,7 +667,7 @@ def test_benchmark_name_is_at_most_40_chars_long(self):
667
667
self .logs ['info' ])
668
668
669
669
def test_benchmark_runtime_range (self ):
670
- """Optimized benchmark should run in less then 1000 μs.
670
+ """Optimized benchmark should have runtime between 20 μs and 1000 μs.
671
671
672
672
Even on calm machine, benchmark with runtime of 2500 μs has 1:4 chance
673
673
of being interrupted in the middle of measurement due to elapsed 10 ms
@@ -687,6 +687,8 @@ def measurements(name, runtime):
687
687
688
688
with captured_output () as (out , _ ):
689
689
doctor = BenchmarkDoctor (self .args , BenchmarkDriverMock ([]))
690
+ doctor .analyze (measurements ('Sylph' , 0 ))
691
+ doctor .analyze (measurements ('Unicorn' , 3 ))
690
692
doctor .analyze (measurements ('Cheetah' , 200 ))
691
693
doctor .analyze (measurements ('Hare' , 1001 ))
692
694
doctor .analyze (measurements ('Tortoise' , 500000 ))
@@ -697,6 +699,18 @@ def measurements(name, runtime):
697
699
698
700
self .assertIn ('runtime: ' , output )
699
701
self .assertNotIn ('Cheetah' , output )
702
+ self .assert_contains (["'Sylph' execution took 0 μs." ],
703
+ self .logs ['error' ])
704
+ self .assert_contains (
705
+ ["Ensure the workload of 'Sylph' has a properly measurable size"
706
+ " (runtime > 20 μs) and is not eliminated by the compiler (use "
707
+ "`blackHole` function if necessary)." ],
708
+ self .logs ['info' ])
709
+ self .assert_contains (["'Unicorn' execution took 3 μs." ],
710
+ self .logs ['warning' ])
711
+ self .assert_contains (
712
+ ["Increase the workload of 'Unicorn' to be more than 20 μs." ],
713
+ self .logs ['info' ])
700
714
self .assert_contains (["'Hare' execution took at least 1001 μs." ],
701
715
self .logs ['warning' ])
702
716
self .assert_contains (
0 commit comments