This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
new perf test in pat.t: avoid timing failure
authorDavid Mitchell <davem@iabyn.com>
Sat, 9 Apr 2016 12:17:21 +0000 (13:17 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sat, 9 Apr 2016 12:37:56 +0000 (13:37 +0100)
A new performance test in re/pat.t added by v5.23.9-58-gd14d585 could
occasionally fails to a timing issue. It was checking that the the
test took less than 1 sec to run; but since the clock usually has a
granularity of 1 sec, it could fail if the test ran over a tick boundary.

Change the condition to <= 1 sec, and increase the time the test takes on
a bad perl - it was taking 4sec on my system; it now takes about 14sec,
so there's less chance of a bad perl passing.

t/re/pat.t

index 906ffc8..73eadd9 100644 (file)
@@ -1762,12 +1762,12 @@ EOP
             # [perl #127855] Slowdown in m//g on COW strings of certain lengths
             my $elapsed= -time;
             my $len= 4e6;
-            my $zeros= 10000;
+            my $zeros= 40000;
             my $str= ( "0" x $zeros ) . ( "1" x ( $len - $zeros ) );
             my $substr= substr( $str, 1 );
             1 while $substr=~m/0/g;
             $elapsed += time;
-            ok( $elapsed < 1, "should not COW on long string with substr and m//g");
+            ok( $elapsed <= 1, "should not COW on long string with substr and m//g");
         }
 } # End of sub run_tests