From: "Aleksi Niemelä" Date: 2001-01-23T01:40:04+09:00 Subject: [ruby-talk:9721] Re: Ruby vs. Python and Euphoria: sieve benc hmark > > This is a MIME message in the multipart format > > Can you repost your question and attachment in plain-text format? This is what I'd expect the python program to be. Say ruby -r base64 -e'puts decode64("IyBwc..his attachment..Q0KDQo=")' - Aleksi # prime sieve in Python # set 1 higher for Python for-loop: BATCH = 51 BENCH_TIME = 15 # how many seconds to run benchmark SIZE = 500 ON = 1 OFF = 0 from time import clock def sieve(): global flags count = 0 flags = [ON]*(SIZE+1) for i in range(1, SIZE): still_prime = flags[i] if still_prime: prime = 2 * i prime = prime + 1 start = prime + i for k in range(start, SIZE, prime): flags[k] = OFF count = count + 1 return count def main(): global flags print "prime sieve benchmark ..." cycles = 0 t = clock() while clock() < t + BENCH_TIME: for i in range(0, BATCH): nprimes = sieve() if nprimes != 167: print "whoops!" cycles = cycles + BATCH t = clock() - t print "%g sieves per second" % (cycles / t) print "%3d" % 2, for i in range(1, SIZE): if flags[i]: print "%3d" % (i*2+1), main()