From: Thomas Bowditch Date: Fri, 20 Nov 1998 17:43:46 +0000 (-0500) Subject: Benchmark.pm suggestion X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=705cc2552a6910dd0106708eca1060809507816d;p=p5sagit%2Fp5-mst-13.2.git Benchmark.pm suggestion To: jhi@iki.fi, Tim.Bunce@ig.co.uk Message-Id: <199811202243.RAA26252@harp.camb.inmet.com> Added timesum(). p4raw-id: //depot/cfgperl@2256 --- diff --git a/lib/Benchmark.pm b/lib/Benchmark.pm index a28f510..ef12d02 100644 --- a/lib/Benchmark.pm +++ b/lib/Benchmark.pm @@ -124,6 +124,11 @@ The COUNT can be zero or negative, see timethis(). Returns the difference between two Benchmark times as a Benchmark object suitable for passing to timestr(). +=item timesum ( T1, T2 ) + +Returns the sum of two Benchmark times as a Benchmark object suitable +for passing to timestr(). + =item timestr ( TIMEDIFF, [ STYLE, [ FORMAT ] ] ) Returns a string that formats the times in the TIMEDIFF object in @@ -293,6 +298,15 @@ sub timediff { bless \@r; } +sub timesum { + my($a, $b) = @_; + my @r; + for (my $i=0; $i < @$a; ++$i) { + push(@r, $a->[$i] + $b->[$i]); + } + bless \@r; +} + sub timestr { my($tr, $style, $f) = @_; my @t = @$tr;