From: Chia-liang Kao Date: Mon, 23 Feb 2004 22:53:51 +0000 (+0800) Subject: Benchmark for child processes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=33e4b5a9a1796aefffe3aa9613e9ae84909ceb74;p=p5sagit%2Fp5-mst-13.2.git Benchmark for child processes Message-ID: <20040223145351.GH94376@portege.clkao.org> p4raw-id: //depot/perl@22362 --- diff --git a/lib/Benchmark.pm b/lib/Benchmark.pm index d7e34f8..d48f8f2 100644 --- a/lib/Benchmark.pm +++ b/lib/Benchmark.pm @@ -412,6 +412,9 @@ All bugs found while writing a regression test. September, 2002; by Jarkko Hietaniemi: add ':hireswallclock' special tag. +February, 2004; by Chia-liang Kao: make cmpthese and timestr use time +statistics for children instead of parent when the style is 'nop'. + =cut # evaluate something in a clean lexical environment @@ -432,7 +435,7 @@ our(@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION); clearcache clearallcache disablecache enablecache); %EXPORT_TAGS=( all => [ @EXPORT, @EXPORT_OK ] ) ; -$VERSION = 1.052; +$VERSION = 1.06; # --- ':hireswallclock' special handling @@ -594,7 +597,8 @@ sub timestr { $r,$pu,$ps,$pt) if $style eq 'noc'; $s=sprintf("$w wallclock secs (%$f cusr + %$f csys = %$f CPU)", $r,$cu,$cs,$ct) if $style eq 'nop'; - $s .= sprintf(" @ %$f/s (n=$n)", $n / ( $pu + $ps )) if $n && $pu+$ps; + $s .= sprintf(" @ %$f/s (n=$n)", $n / ( $style eq 'nop' ? $cu + $cs : $pu + $ps )) + if $n && ($style eq 'nop' ? $cu+$cs : $pu+$ps); $s; } @@ -882,7 +886,8 @@ sub cmpthese{ for (@vals) { # The epsilon fudge here is to prevent div by 0. Since clock # resolutions are much larger, it's below the noise floor. - my $rate = $_->[6] / ( $_->[2] + $_->[3] + 0.000000000000001 ); + my $rate = $_->[6] / (( $style eq 'nop' ? $_->[4] + $_->[5] + : $_->[2] + $_->[3]) + 0.000000000000001 ); $_->[7] = $rate; }