Created
July 5, 2014 11:49
-
-
Save muayyad-alsadi/8c8a8fc6bf698fff8517 to your computer and use it in GitHub Desktop.
do not benchmark yield
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def get_primes(n): | |
compo=set() | |
for i in xrange(2, n): | |
if i in compo: continue | |
yield i | |
compo.update(xrange(i*2, n,i)) | |
def benchmark(f, n): | |
def wrapped(*a, **kw): | |
t0=time.time() | |
for i in xrange(n): f(*a, **kw) | |
print "dt=", time.time()-t0 | |
return wrapped | |
benchmark(get_primes, 500)(10000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment