This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Benchmark.t/.pm: deal with short times
authorDavid Mitchell <davem@iabyn.com>
Thu, 26 Nov 2015 15:41:01 +0000 (15:41 +0000)
committerDavid Mitchell <davem@iabyn.com>
Thu, 26 Nov 2015 16:04:54 +0000 (16:04 +0000)
commit8dddc15610773a292e6fe8f989e51dd8c27ac1de
tree48d2f92ed26a38e3b2d0c18da3d28f60a9805aeb
parentbabeed279c5f867ce4148669b3bf8f30e8254a9f
Benchmark.t/.pm: deal with short times

The number of iterations to do on various tests was set at 3 or 10
in the first incarnation of the test file 13 years ago, and hasn't
changed since. In the meantime, CPUs have gotten faster. So bump the
iteration count to 100. This makes no appreciable difference to total wall
time for the test file on my newish x86_64 platform, but will hopefully
make tests less likely to be running within the noise of  a single 100Hz
clock tick.

In particular, the NetBSD smokes were quite frequently failing tests 127
and 128, due to the CPU taken to do an empty loop being greater than that
for a full loop, thus leading to negative apparent execution time.  This
was likely to be due to the first taking "1" clock tick and the second
taking "0" ticks. Although this is less likely to happen now that the
iterations has been increased, this commit also adds a check to
Benchmark.pm for a negative apparent execution time, and if detected,
prints a "too few iterations" warning and resets it to zero.
lib/Benchmark.pm
lib/Benchmark.t