2010/7/9 H.Merijn Brand <h.m.brand@xs4all.nl>:
> On Thu, 8 Jul 2010 23:03:43 +0100, Tim Bunce <Tim.Bunce@pobox.com>
>> I think many people consider the cost of sub/method calls a significant
>> issue. Here's a little bit of code that exercises sub calls with args,
>> recursion, object creation/destruction, and hash creation. It runs on
>> all perl versions and can easily be tuned to suit the cpu performance:
>>
>> $ time perl -e 'sub f { my($n)=@_; my $h=bless { 1..10 }; return $n if $n < 2; f($n-1)+f($n-2) } f(25)'
The ackerman with 25 recursions is probably to small. I used 28 to get
longer runtimes > 5 sec < 30 sec.
Some array access, simple IO and string (regex + realloc) should
probably be added.
A Schwartzian Transform maybe.
And use of a big core module. I use Module::Build in my tests because
this is the biggest op-wise and the worst.
$ time $perl -e 'sub f { my($n)=@_; my $h=bless { 1..10 }; return $n
if $n < 2; f($n-1)+f($n-2) } f(28)'
> perl-xxx -we 'sub f {my($n)=@_;my$h=bless{1..10};$n < 2 and return $n; f ($n-1)+f ($n-2) } f (25)'
> elapsed pass perl
> ========== ==== =================
> 0.63581 PASS base/perl5.00504
> 0.67038 PASS /pro/bin/perl
> 0.67369 PASS base/perl5.00503
> 0.67783 PASS base/perl5.6.1
> 0.68062 PASS base/perl5.8.2
> 0.69003 PASS base/perl5.8.0
> 0.69417 PASS base/perl5.6.0
> 0.69434 PASS base/perl5.8.7
> 0.70626 PASS base/perl5.8.9
> 0.71174 PASS base/perl5.8.3
> 0.71296 PASS base/perl5.6.2
> 0.72446 PASS base/perl5.8.8
> 0.72611 PASS base/perl5.8.6
> 0.72633 PASS base/perl5.8.1
> 0.72854 PASS base/perl5.8.5
> 0.73124 PASS base/perl5.8.4
> 0.78452 PASS base/perl5.13.1
> 0.78913 PASS base/perl5.10.1
> 0.79917 PASS base/perl5.11.5
> 0.80482 PASS base/perl5.10.0
> 0.81939 PASS base/perl5.13.2
> 0.82824 PASS /usr/bin/perl
> 0.85254 PASS base/perl5.11.1
> 0.85389 PASS base/perl5.12.1
> 0.85619 PASS base/perl5.13.0
> 0.85835 PASS base/perl5.11.0
> 0.86044 PASS base/perl5.12.0
> 0.86744 PASS base/perl5.11.2
> 0.87308 PASS base/perl5.11.3
> 0.90674 PASS base/perl5.11.4
> 1.03253 PASS base/perl5.00405
> 1.21093 PASS base/perl5.00307
Now THIS starts to look like what I saw before.
--
Reini Urban
http://phpwiki.org/ http://murbreak.at/
Thread Previous
|
Thread Next