Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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...

/\/\averick


Comment on RE: RE: sieve of Eratosthenes
Select or Download Code
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.
    -ase

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://20744]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2015-07-03 11:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls