4 ms·
This seems like a very odd standard to use? I understand that you wanted to compare performances of different languages, that's great. But if you actually wan
by colomon 7y ago
This seems like a very odd standard to use? I understand that you wanted to compare performances of different languages, that's great.
But if you actually wanted to get the job done idiomatically, the code is one short, simple line of Perl 6. The performance, while admittedly slower, is within the same order of magnitude as your Perl 5 version.
To me, this is the magic of Perl 6. Sure, if you want to use 16 lines of loopy integer-crunching code to calculate the first N primes and you care about speed, Perl 6 should not be your choice. On the other hand, if you'd prefer to say
(1..$N).grep(*.is-prime)
and get the answer back in reasonable speed, Perl 6 is perfect.
- 6thaccount2 7y agoThat is impressive!
- petre 7y agoIt's just stuff that I use daily in normal code, so this benchmark pretty much serves the pupose very well: it uses mundane operations, also uses memory, one can adjust it by raising the bar 10x times, so the actual algorithm takes several orders of magnitude longer than the JIT penalty. In fact most of the interpreted languages would pretty much crunch for minutes at 10⁴, while Go, Crystal, D and Rust would take seconds or tens of seconds. Perl6 is basically stuck there forever and at the other end of the spectrum are Node and Dart. LuaJIT would run out of memory at that figure, otherwise it's among the fastest.