[Pdx-pm] Comparing Rakudo and Perl 5 with Euler Project Problems

Jonathan Leto jaleto at gmail.com
Wed Jul 8 16:42:16 PDT 2009


Howdy,

Here are two solutions to Euler Problem #1 [0], one in Rakudo, the
other in Perl 5:

$ time ./perl6 -e 'say [+] grep { $_ % 3 == 0 or $_ % 5 == 0}, (1..1000);'
234168

real	0m8.819s
user	0m3.193s
sys	0m0.256s

$ time perl -e 'map { $sum+=$_ } grep { $_ % 3 == 0 or $_ % 5 == 0 }
(1..1000); print "$sum\n"'
234168

real	0m0.016s
user	0m0.004s
sys	0m0.008s

It is also interesting to time the interpreter load time:

$ time perl -e42

real	0m0.013s
user	0m0.002s
sys	0m0.007s

$ time ./perl6 -e42

real	0m2.054s
user	0m1.503s
sys	0m0.192s

Disregarding interpreter load time, it seems that Perl 5 is currently
about 600 times faster for this algorithm.


[0] http://projecteuler.net/index.php?section=problems&id=1

-- 

Jonathan Leto
jonathan at leto.net
http://leto.net


More information about the Pdx-pm-list mailing list