Front page | perl.perl5.porters |
Postings from September 2010
[perl #72668] Benchmark.t test 24 bug
From:
Father Chrysostomos via RT
Date:
September 26, 2010 17:15
Subject:
[perl #72668] Benchmark.t test 24 bug
Message ID:
rt-3.6.HEAD-5116-1285546522-648.72668-14-0@perl.org
On Tue Feb 09 20:06:14 2010, toddr@cpanel.net wrote:
> Test 24 is failing for me on some systems:
>
> # Failed test 'timestr ($diff, "noc")'
> # at lib/Benchmark.t line 123.
> # ' 7 wallclock secs ( 7.03 usr + 0.04 sys = 7.07
> CPU)'
> # doesn't match '(?-xism:7 +wallclock secs? +\( *7.03 +usr +\+
> +0.04 +sys += +7.08 +CPU\))'
>
> The Test:
> my $noc = timestr ($diff, 'noc');
> like ($noc, qr/$wallclock +wallclock secs? +\( *$usr +usr +\+ +$sys
> +sys += +$cpu +CPU\)/, 'timestr ($diff, "noc")');
>
> When I dig into this test, It appears that $cpu is generated from the
> regex by parsing the 'all' output:
> my $all = timestr ($diff, 'all');
> my ($wallclock, $usr, $sys, $cusr, $csys, $cpu) = $all =~
> $All_Pattern;
>
> This means that the expectation is that the CPU time for 'all' output
> will match the CPU time for 'noc' output.
> CPU time is calculated...
> for 'all': $tr->cpu_a
> for' noc': $tr->cpu_p
>
> The code to calculate the CPU for each of these is:
> sub cpu_p { my($r,$pu,$ps,$cu,$cs) = @{$_[0]}; $pu+$ps ; }
> sub cpu_a { my($r,$pu,$ps,$cu,$cs) = @{$_[0]}; $pu+$ps+$cu+$cs ; }
>
> What this means: The only way test 24 can succeed is if $cu and $cs
> are 0. In my case, extra diag messages show that $cu was 0.01 and
> this caused the test to fail.
> Suggested Patch: There are no comments in the test file to indicate if
> we're validating formatting or the math on this. I'm inclined to go
> with formatting so I suggest the following patch for test 24, which
> will match what test 25 for 'nop' output is doing.
>
> --- a/lib/Benchmark.t
> +++ b/lib/Benchmark.t
> @@ -114,7 +114,7 @@ is ($auto, $default, 'timestr ($diff, "auto")
> matches timestr ($diff)');
> is (timestr ($diff, 'none'), '', "none supresses output");
>
> my $noc = timestr ($diff, 'noc');
> - like ($noc, qr/$wallclock +wallclock secs? +\( *$usr +usr +\+
> +$sys +sys += +$cpu +CPU\)/, 'timestr ($diff, "noc")');
> + like ($noc, qr/$wallclock +wallclock secs? +\( *$usr +usr +\+
> +$sys +sys += +\d+\.\d\d +CPU\)/, 'timestr ($diff, "noc")');
>
> my $nop = timestr ($diff, 'nop');
> like ($nop, qr/$wallclock +wallclock secs? +\( *$cusr +cusr +\+
> +$csys +csys += +\d+\.\d\d +CPU\)/, 'timestr ($diff, "nop")');
>
>
>
I’ll apply this if no one objects within the next few days.
-
[perl #72668] Benchmark.t test 24 bug
by Father Chrysostomos via RT