When the first version of Rakudo Star came out, I was eager to try it, but I was, erm, somewhat underwhelmed by the fact that its performance was not quite up to what some people might have expected:

$ time ./perl6 -e 'my $s; for 1..10000 {$s+=1/$_**2};say $s' 1.64483407184806 real 0m38.387s user 0m38.154s sys 0m0.232s $ time perl -E 'my $s; for (1..10000) {$s+=1/$_**2};say $s' 1.64483407184806 real 0m0.009s user 0m0.008s sys 0m0.004s

One year later, I've tried the same "benchmark" with Rakudo Star 2011.07:

time ./perl6 -e 'my $s; for 1..10000 {$s+=1/$_**2};say $s' 1.64483407184806 real 0m9.588s user 0m9.513s sys 0m0.068s

Well, it's an improvement.

Now, the latest version (2012.01) came out, supposedly with great improvements, so I thought I'd try it.

To my great consternation the same script didn't complete within three minutes. I tried to lower the loop range:

time ./perl6 -e 'my $s; for 1..1000 {$s+=1/$_**2};say $s' NaN real 0m2.164s user 0m2.080s sys 0m0.080s

Note that the result is incorrect (it is a number actually).

I've tried other ranges:

n of iterresulttime
2001.639946546853190.799
400NaN0.937
600NaN1.195
800NaN1.592
1000NaN2.179
1200NaN2.972

A very pronounced O(N2) trend can be observed here. Is this a known problem? Because it is a problem: there is nothing in the algorithm that would imply such a quadratic behavior, and indeed, with Rakudo 2011.07, elapsed time grows linearly with the number of iterations.

As to the NaN,

./perl6 -e 'my $s; for 1..358 {$s+=1/$_**2};say $s' 1.64214466837792 ./perl6 -e 'my $s; for 1..359 {$s+=1/$_**2};say $s' NaN

To paraphrase a certain presentation about weird programming languages that's become popular lately,

WAT


In reply to Perl 6 and performance by kikuchiyo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.