Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

RE: RE: sieve of Eratosthenes

by maverick (Curate)
on Jul 01, 2000 at 17:43 UTC ( #20744=note: print w/replies, xml ) Need Help??

in reply to RE: sieve of Eratosthenes
in thread sieve of erothenes

Nice algorithm! The idea of using vectors never occured to me.

I went back and uncomment the print statements to see what kind of overhead the grep might cause. At N=100000 I end up with:

Benchmark: timing 100 iterations of Ase, Maverick... Ase: 142 wallclock secs (141.93 usr + 0.04 sys = 141.97 CPU) Maverick: 166 wallclock secs (166.05 usr + 0.00 sys = 166.05 CPU)
I would have expected us to end up with closer times, but your's ends up being 24 seconds faster? wow. So, I removed the prints and got:
Benchmark: timing 100 iterations of Ase, Maverick... Ase: 122 wallclock secs (121.11 usr + 0.00 sys = 121.11 CPU) Maverick: 164 wallclock secs (164.65 usr + 0.03 sys = 164.68 CPU)
I'm running this on a PII 400, using Red Hat Linux and the stock perl RPM (5.005_03). It would seem that vec is much faster under Linux than under windows.

Hmmm...I wonder how these benchmark out on other platforms...


Replies are listed 'Best First'.
RE: RE: RE: sieve of Eratosthenes
by ase (Monk) on Jul 02, 2000 at 06:50 UTC
    I wish I could claim the algorithm for my own, but I can't.. Ironically enough, I got it from "More Programming Pearls" by Jon Bentley (nothing to do with perl as its copyright date is 1988) He deals mostly with awk but I highly recommend it as well as its out of print predecessor "Programming Pearls"... which I was able to obtain a while ago.... good stuff for any programmer.

    I would also be interested in benchmarks on other platforms.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://20744]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2017-12-14 03:49 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (384 votes). Check out past polls.