develooper Front page | perl.perl5.porters | Postings from February 2004

[PATCH] Benchmark for child processes

Thread Next
From:
Chia-liang Kao
Date:
February 23, 2004 07:12
Subject:
[PATCH] Benchmark for child processes
Message ID:
20040223145351.GH94376@portege.clkao.org
Here's patch making Benchmark easier to be abused to benchmark
external commands in addition to Perl code. It makes cmpthese and
timestr use time statistics for children instead of parent when the
style is 'nop'.

--- lib/Benchmark.pm.orig	Fri Feb 20 20:51:04 2004
+++ lib/Benchmark.pm	Sun Feb 22 23:38:13 2004
@@ -594,7 +594,8 @@
 			    $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 +883,8 @@
     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;
     }


Cheers,
CLK

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About