SPUG: Benchmark.pm broken?
Tim Maher/CONSULTIX
tim at consultix-inc.com
Thu Jan 20 17:03:31 CST 2000
SPUG-sters,
I'm comparing the code samples below for execution time, and
Benchmark.pm is giving funny results, including fields it doesn't
show me for other code samples (cusr, csys) and a total CPU time of 0.00.
Anybody know what's wrong here?
-Tim
P.S. Once this gets working, I'll compare these two with a Schwartzian
Transformation version.
#! /usr/local/bin/perl -w
use Benchmark;
$count=200;
# first argument is the desired number of runs of each code sample
# second is an "anonymous hash", containing keys pointing
# to quoted code samples
timethese($count, {
first => ' # must backslash any SQs in code samples!
@stuff=sort {
($mtime{$a} ||= -M $a)
<=>
($mtime{$b} ||= -M $b)
} <*> ;
# print "Results: $_\n";
' # end of quoted code sample
, # this comma separates the two code samples being compared
second => '
# no-cacheing version
@stuff=sort { -M $a <=> -M $b } <*> ;
' # end of quoted code sample
}
);
print "\nPerl Version: $]\n";
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Here's output from a sample run:
Benchmark: timing 50 iterations of first, second...
first: 4 wallclock secs ( 0.09 usr 0.11 sys + 0.84 cusr 2.33 csys = 0.00 CPU)
second: 3 wallclock secs ( 0.05 usr 0.20 sys + 0.83 cusr 2.38 csys = 0.00 CPU)
Perl Version: 5.00502
(results same with 5.00503, and different numbers of iterations)
Anybody understand what's wrong here?
*========================================================================*
| Tim Maher, PhD Consultix & (206) 781-UNIX/8649 |
| Pacific Software Gurus, Inc Email: tim at consultix-inc.com |
| UNIX/Linux & Perl Training http://www.consultix-inc.com |
| 2/22: UNIX 2/28: Perl Modules 2/29: Int. Perl 3/3: Pattern Matching |
*========================================================================*
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
Email to majordomo at pm.org: ACTION spug-list your_address
More information about the spug-list
mailing list