Perlito5
view release on metacpan or search on metacpan
lib/Perlito5X/Benchmark.pm view on Meta::CPAN
703704705706707708709710711712713714715716717718719720721722723# Wait for the user timer to tick. This makes the error range more like
# -0.01, +0. If we don't wait, then it's more like -0.01, +0.01. This
# may not seem important, but it significantly reduces the chances of
# getting a too low initial $n in the initial, 'find the minimum' loop
# in &countit. This, in turn, can reduce the number of calls to
# &runloop a lot, and thus reduce additive errors.
#
# Note that its possible for the act of reading the system clock to
# burn lots of system CPU while we burn very little user clock in the
# busy loop, which can cause the loop to run for a very long wall time.
# So gradually ramp up the duration of the loop. See RT #122003
#
my
$tbase
= Benchmark->new(0)->[1];
my
$limit
= 1;
while
( (
$t0
= Benchmark->new(0) )->[1] ==
$tbase
) {
for
(
my
$i
=0;
$i
<
$limit
;
$i
++) {
my
$x
=
$i
/ 1.5 }
# burn user CPU
$limit
*= 1.1;
}
$subref
->();
$t1
= Benchmark->new(
$n
);
( run in 0.481 second using v1.01-cache-2.11-cpan-d6f9594c0a5 )