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 iter | result | time |
200 | 1.63994654685319 | 0.799 |
400 | NaN | 0.937 |
600 | NaN | 1.195 |
800 | NaN | 1.592 |
1000 | NaN | 2.179 |
1200 | NaN | 2.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
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |