korpenkraxar's Journal http://use.perl.org/~korpenkraxar/journal/ korpenkraxar's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-02-08T17:46:17+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 korpenkraxar's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~korpenkraxar/journal/ How to compare and benchmark Perl5 and Perl6 performance? http://use.perl.org/~korpenkraxar/journal/39051?from=rss Hi all!<br> <br> I am a big Perl fan and biologist who write and use Perl 5 daily for my studies of animal evolution. Perl is really big in the bioinformatics field, but I guess you all already knew that. Looking at the novel features of Perl 6, it seems as I and others in my field would enjoy using this version of the language even more<nobr> <wbr></nobr>:-)<br> <br> Today I finally came around to downloading and compiling Rakudo Perl 6 and Parrot, which to my pleasant surprise was just as simple as detailed here <a href="http://rakudo.org/how-to-get-rakudo/">http://rakudo.org/how-to-get-rakudo/</a> on my Archlinux X86_64 box. Your mileage may vary depending on OS, but most Linux distributions make it very easy for you to install the prerequisites you need to pull this off. You need stuff like the GNU C compiler, git, subversion and Perl 5, all of which are easily tracked down in your distro's package manager.<br> <br> To make things clear before I go on: I am <b>not</b> a computer scientist or professional, full-time programmer. I simply use Perl because it lets me solve lots of data parsing, mining and analysis problems very quickly and close to how I think about the problem. That said, I am of course happy for all the performance optimizations I can get while running my perl scripts and programs. Speed of execution matters too, just as speed of development, and Perl 5 strikes a very nice balance for the stuff I am doing.<br> <br> Using Perl 6 as programming language for day-to-day use in solving problems relevant to me also requires the Parrot interpreter/compiler to produce <i>efficient code</i>. I am unlikely to enjoy the nifty language novelties in Perl 6 if the code is horribly slow compared to what I am used to.<br> <br> I decided to compare something really simple in Perl 5 and Perl 6 and just increment a number and put that number in the last cell of a growing array.<br> <br> This is the Perl 5 version:<br> <br> <code> <br> #!/usr/bin/perl -w<br> <br> my $i = 0;<br> <br> my @numbers;<br> <br> until ( $i == 100000 ) {<br> <br> $numbers[$i] = $i;<br> <br> $i++;<br> <br> }<br> </code> <br> <br> Perl5: ~0.07s to complete, uses 26KB RAM at completion.<br> <br> This is the corresponding Perl 6 version (bare with me, I do not know much Perl 6 yet so I really just translated the above code with minimal changes):<br> <br> <code> <br> use v6;<br> <br> my Int $i = 0;<br> <br> my @numbers;<br> <br> until ( $i == 100000 ) {<br> <br> @numbers[$i] = $i;<br> <br> $i++;<br> <br> }<br> </code> <br> <br> Rakudo Perl6: ~1m14s to complete, uses 1.4GB RAM at completion.<br> <br> In this simple comparison, the Perl 5 implementation is &gt;1000 times faster than Perl 6, which also uses &gt;50000 times more memory than Perl 5.<br> <br> Ouch.<br> <br> I do not (want to?) believe this difference is due to the the way the new language is implemented and running in Parrot per se, but expect this to be due to lack of optimization and presence of bugs and leaks and perhaps my own ignorance of Perl 6. However, if this arbitrary code snippet is representative of the kind of performance regressions facing people curious to try the Rakudo implementation of Perl 6 out, it may be difficult to attract early adopters outside the core of the community for a while.<br> <br> The problem is, how can I as a "real-world user" best track the development of Perl 6 from a performance perspective? Are there official or semi-official benchmark scripts around already that we could use?<br> <br> I have a suggestion, which is to try implementing at least some of the benchmarks over at the The Computer Language Benchmarks Game <a href="http://shootout.alioth.debian.org/">http://shootout.alioth.debian.org/</a> in Perl 6. Is there someone around here who is interested in trying this out? Perhaps we could make a challenge out of it or something<nobr> <wbr></nobr>:-) korpenkraxar 2009-05-29T22:58:35+00:00 journal