Ovid said:
This is part of a larger set of code which is intended to be pure Perl, ...
Can you write a "half descent sieve" in Perl?
Also, how about if you want the 2e6 through 3e6 primes the first time you call and the 1e6 through 2e6 the second time?
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
I wasn't responding to Ovid. I was responding to Anonymous Monk's thoughts on sieving vs reading from disk - which I took to be of a more general nature (ie not in relation to just "pure perl").
I honestly don't know whether a "pure perl" sieve would beat reading from disk. I might give it a whirl later today, if I get time. (Or has somebody else already done compararive benchmarking ?)
Cheers, Rob
| [reply] |
Using a fairly highly tuned C implementation of a Sieve of Atkin prime generator, finding the 15 millionth prime takes just over one second. Using my load and lookup Perl takes just under to do the same thing.
I think it doubtful that a pure perl implementation could achieve anywhere near this performance, as the C implementation is using hand-coded optimisations for 32-bit math--unwinding loops; using lookups instead of division; tailoring to L1 cache sizes etc. But you might prove me wrong :)
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |