summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-07-19 23:10:50 +0100
committerDavid Mitchell <davem@iabyn.com>2013-07-19 23:10:50 +0100
commit9eba9e102c2f8c2ec41a50f4bbe6b09a64dddd31 (patch)
tree662107a2b8bf3b9d4ad86e876d0c8b3d30f62ff7
parent3164fde474d170d03f8bbf31ee203012c027f711 (diff)
downloadperl-9eba9e102c2f8c2ec41a50f4bbe6b09a64dddd31.tar.gz
Benchmark.t: remove CPU-speed-sensitive test
Benchmark.t has been randomly failing test 15 in smokes for ages. This is the one that checks that a loop run 3*N times burns approximately 3 times more CPU than when run just N times. For the last month the test has included a calibration loop and test, which does much the same thing, but without using any code from Benchmark.pm. This has failed just as much, which confirms that its an issue with the smoke host (such as a variable speed CPU or whatever), rather than any flaw in the Benchmark.pm library logic. So just remove the calibration loop and the dodgy test.
-rw-r--r--lib/Benchmark.t81
1 files changed, 1 insertions, 80 deletions
diff --git a/lib/Benchmark.t b/lib/Benchmark.t
index 1b8d4b4975..177af104fb 100644
--- a/lib/Benchmark.t
+++ b/lib/Benchmark.t
@@ -8,7 +8,7 @@ BEGIN {
use warnings;
use strict;
use vars qw($foo $bar $baz $ballast);
-use Test::More tests => 197;
+use Test::More tests => 195;
use Benchmark qw(:all);
@@ -56,67 +56,6 @@ timeit( 1, sub { $foo = @_ });
is ($foo, 0, "benchmarked code called without arguments");
-print "# Burning CPU to see if clock is consistent...\n";
-
-# Run some code for approx 3 secs, then for 1 sec. If the first doesn't
-# take appoex 3 times longer than the second, then skip any tests which
-# require a consistent clock
-
-my $INCONSISTENT_CLOCK = 0;
-my $calibration;
-
-{
- my ($t0, $t1, $tdelta);
-
- $t0 = times; 1 while times == $t0; # wait for OS clock to tick
-
- # guess approx n for code to run for 1 sec
- my $n = 1;
- while ($n < 1_000_000_000) { # eventually stop in worst case
- $t0 = times;
- fib($ballast) for 1..$n;
- $t1 = times;
- $tdelta = ($t1 - $t0);
- last if ($tdelta) >= 1.0;
- $n *= 2;
- }
- print "# did $n iterations in $tdelta sec\n";
-
- # adjust n for exactly one second
- $n /= $tdelta;
-
- # now run enough loops for approx 3 secs
-
- $t0 = times; 1 while times == $t0; # wait for OS clock to tick
- $t0 = times;
- fib($ballast) for 1..($n*3);
- $t1 = times;
- my $td3 = ($t1 - $t0);
- print "# approx 3 sec delta is $td3 secs\n";
-
- # now run enough loops for approx 1 sec
-
- $t0 = times; 1 while times == $t0; # wait for OS clock to tick
- $t0 = times;
- fib($ballast) for 1..$n;
- $t1 = times;
- my $td1 = ($t1 - $t0);
- print "# approx 1 sec delta is $td1 secs\n";
-
- # we use 0.7 of $DELTA so that we err on the side of assuming
- # a bad clock and skip tests; otherwise we might be just within the
- # delta here, and just outside the delta on tests, and so get random
- # failures
- unless (cmp_delta(3*$td1, $td3, 0.7*$DELTA)) {
- print "# INCONSISTENT CLOCK! - will skip timing-related tests\n";
- $INCONSISTENT_CLOCK = 1;
- }
- $calibration = $td3/(3*$td1); # for diag output
-
-}
-ok(!$INCONSISTENT_CLOCK, "temporary calibration test");
-
-
print "# Burning CPU to benchmark things; will take time...\n";
# We need to do something fairly slow in the coderef.
@@ -154,24 +93,6 @@ my $in_onesec_adj = $in_onesec;
$in_onesec_adj *= (1/$cpu1); # adjust because may not have run for exactly 1s
print "# in_onesec_adj=$in_onesec_adj adjusted iterations\n";
-SKIP: {
- skip("INCONSISTENT CLOCK", 1) if $INCONSISTENT_CLOCK;
-
- ok(cmp_delta($in_onesec_adj, $estimate, $DELTA),
- "is $in_onesec_adj within $DELTA of estimate ($estimate)?")
- or do {
- diag(" in_threesecs = $in_threesecs");
- diag(" in_threesecs_adj = $in_threesecs_adj");
- diag(" cpu3 = $cpu3");
- diag(" sys3 = $sys3");
- diag(" estimate = $estimate");
- diag(" in_onesec = $in_onesec");
- diag(" in_onesec_adj = $in_onesec_adj");
- diag(" cpu1 = $cpu1");
- diag(" sys1 = $sys1");
- diag(" calibration = $calibration");
- };
-}
# I found that the eval'ed version was 3 times faster than the coderef.
# (now it has a different ballast value)