The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You've indeed hit a regression in Rakudo here. Let me explain it. 1/$_**2 produces a Rat object in Perl 6 if $_ is an integer (it is here). That is, it's a rational number that stores the numerator and denominator as integers. Thus $s is als a Rat, and the way that $s is built makes the denominator grow very fast. Since newest Rakudo has bigint support, the integers can now grow larger than 64bit, and the growing size of the integers causes the O(nē) slowness you observed. The specification says that once the denominator exceeds 2 ** 64 If you use floating point numbers to begin with, you'll get:
niecza correctly implements the fallback to floating point values, and yields the correct result (in 3s on a different machine of mine; it's usually slow to compile stuff, but faster at run time). I've already started a branch to fix the Rat arithmetic issues (branch 'Rational' on github), and I'll try to make it work before the next Star release; I can't promise it though. P.S. I'm sad to see that perlmonks is slowly becoming more like reddit, where problems are met with rancorousness instead of being discussed on a technical level. UPDATE (2012-02-13): I've fixed Rakudo to fall back to Num if the denominator exceeds 2**64, so now you get:
You can get this fix by using the latest development revision from git, or wait for the next release. Thanks again for your feedback. Second update: when running up to 10_000 it takes 2.8s on my machine, so while still a big step away from perl 5 speed, it's faster than your previous measurements. In reply to Re: Perl 6 and performance
by moritz
|
|