[tpm] Perl 6 performance relative to Perl 5.10

Richard vzshzn at gmail.com
Fri Apr 29 15:19:04 PDT 2011


Hey guys.

I had that looping problem when I was playing with Rakudo last year. It's
not actually slow looping, it's slow lists. I presume it's the same
fundamental problem now (although I really should upgrade and test), so I
might as well demonstrate my generic workaround.

$ time perl6 -e 'my $x; for ^1000 { $x++}; say $x'
1000

real    0m6.533s
user    0m6.124s
sys     0m0.364s
$ time perl6 -e 'my $x; for ^10000 { $x++}; say $x'
10000

real    0m49.944s
user    0m48.359s
sys     0m1.140s
$ time perl6 -e 'my ($x, $a) = (0,0); while ($a < 10000) { $a++; $x++}; say
$x'
10000

real    0m6.688s
user    0m6.204s
sys     0m0.408s

So instead of using ^ or .. there which requires a list to be built, I just
manually assign and check a counter variable for perl6 looping

Rather ironically the Benchmark.pm6 distributed then with Rakudo was made
somewhat useless by this problem, so I had to write my own replacement where
I first benchmarked the overhead

Cheers,
Rich

On Fri, Apr 29, 2011 at 4:14 PM, mattp <mattp at cpan.org> wrote:

> Alan,
> Chromatic wrote a more in depth comparison of Perl 5 and Rakudo benchmarks
> a while back:
>
>
> http://www.modernperlbooks.com/mt/2010/07/an-accurate-comparison-of-perl-5-and-rakudo-star.html
>
> Simple benchmarks aren't exactly fair when comparing the two. Though the 60
> second loop was surprising to see, regardless of optimizations / lack there
> of.
>
> Cheers,
> Matt
>
>
> On 04/29/2011 02:33 PM, arocker at Vex.Net wrote:
>
>> I decided to get some numbers to add to last night's discussion. To test
>> the basic overhead, I used a minimal command-line program.
>>
>> As a baseline, the system Perl, 5.10.1 returned the following:
>>
>> time perl -e ";"
>> 0.00 user 0.01 system 0:00.01 elapsed 100%CPU (0 avgtext + 0 avgdata
>>   5712 maxresident)k  (When re-run, even the 1s disappeared.)
>>    0 inputs + 0 outputs (0 major    + 419 minor)pagefaults 0 swaps
>>
>> Perl 6, run 3 times to eliminate the influence of Linux' aggressive
>> caching:
>>
>> time ./perl6 -e ";"
>> 1.52 user 0.16 system 0:02.37 elapsed 70% CPU (0 avgtext + 0 avgdata
>> 263456 maxresident)k
>> 18384 inputs + 0 outputs (45 major+ 16487 minor)pagefaults 0 swaps
>>
>> time ./perl6 -e ";"
>> 1.13 user 0.06 system 0:01.33 elapsed 88% CPU (0 avgtext + 0 avgdata
>> 263440 maxresident)k
>>     0 inputs + 0 outputs (0 major + 16531 minor)pagefaults 0 swaps
>>
>> time ./perl6 -e ";"
>> 1.25 user 0.14 system 0:01.51 elapsed 91% CPU (0 avgtext + 0 avgdata
>> 263440 maxresident)k
>>     0 inputs + 0 outputs (0 major + 16531 minor)pagefaults 0 swaps
>>
>> (I'm at a loss to explain the increase on the 3rd try of Perl 6.)
>>
>> Giving the program something real to do seems to add very little work:
>>
>> time perl -e 'print "present\n";'
>> present
>> 0.00 user 0.00 system 0:00.00 elapsed 0% CPU (0 avgtext + 0 avgdata
>>   6096 maxresident)k
>>     0 inputs + 0 outputs (0 major +   443 minor)pagefaults 0 swaps
>>
>> time ./perl6 -e "say 'present';"
>> present
>>  1.22 user 0.09 system 0:01.41 elapsed 92% CPU (0 avgtext + 0 avgdata
>> 263600 maxresident)k
>>     0 inputs + 0 outputs (0 major + 16542 minor)pagefaults 0 swaps
>> time ./perl6 -e "say 'present';"
>> present
>>  1.39 user 0.21 system 0:01.76 elapsed 90% CPU (0 avgtext + 0 avgdata
>> 263616 maxresident)k
>>     0 inputs + 0 outputs (0 major + 16542 minor)pagefaults 0 swaps
>>
>> To see the effect of a reasonable number of arithmetic operations:
>>
>> time perl -e "my \$x; for (1..100000){\$x++}; print \"\$x\n\";"
>> 100000
>>  0.01 user 0.00 system 0:00.02 elapsed 45% CPU (0 avgtext + 0 avgdata
>> 6352 maxresident)k
>>    0 inputs + 0 outputs (0 major +   459 minor)pagefaults 0 swaps
>>
>> time ./perl6 -e "my \$x; for 1..100000 {\$x++}; say \"\$x\";"
>> 100000
>> 55.59 user 0.75 system 1:02.7 0elapsed 89% CPU (0 avgtext + 0 avgdata
>> 601952 maxresident)k
>>   0 inputs + 0 outputs (0 major + 40452 minor)pagefaults 0 swaps
>>
>> Rather significant differences.
>>
>>
>>
>>
>> _______________________________________________
>> toronto-pm mailing list
>> toronto-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/toronto-pm
>>
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20110429/75ee2d64/attachment.html>


More information about the toronto-pm mailing list