From 59000498ecb28d4767eac94dc70de651f1b3c03e Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Mon, 21 Oct 2013 13:45:36 +0100 Subject: [PATCH] Benchmark.t: avoid ultra-lightweight code Some tests benchmarked the code '$i++', which is so lightweight that it could trigger the die "Timing is consistently zero in estimation loop" in Benchmark.pm. So make the code slightly more heavyweight. --- lib/Benchmark.t | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Benchmark.t b/lib/Benchmark.t index 177af10..7706bba 100644 --- a/lib/Benchmark.t +++ b/lib/Benchmark.t @@ -401,7 +401,9 @@ sub check_graph { { select(OUT); my $start = times; - my $chart = cmpthese( -0.1, { a => "++\$i", b => "\$i = sqrt(\$i++)" }, "auto" ) ; + my $chart = cmpthese( -0.1, { a => "\$i = sqrt(\$i++) * sqrt(\$i)", + b => "\$i = sqrt(\$i++)", + }, "auto" ) ; my $end = times; select(STDOUT); ok (($end - $start) > 0.05, "benchmarked code ran for over 0.05 seconds"); @@ -423,7 +425,8 @@ sub check_graph { { select(OUT); my $start = times; - my $chart = cmpthese( -0.1, { a => "++\$i", b => "\$i = sqrt(\$i++)" } ) ; + my $chart = cmpthese( -0.1, { a => "\$i = sqrt(\$i++) * sqrt(\$i)", + b => "\$i = sqrt(\$i++)" }); my $end = times; select(STDOUT); ok (($end - $start) > 0.05, "benchmarked code ran for over 0.05 seconds"); -- 2.7.4