Skip to content

Instantly share code, notes, and snippets.

@iizukak
Created December 16, 2011 06:44
Show Gist options
  • Save iizukak/1484837 to your computer and use it in GitHub Desktop.
Save iizukak/1484837 to your computer and use it in GitHub Desktop.
Benchmark for PyPy's numpypy
#Simple benchmark for PyPy's numpypy
#Based on https://bitbucket.org/pypy/pypy/src/dd3bcd84b145/pypy/module/micronumpy/bench/
import time
try:
import numpypy as numpy
except:
import numpy
def add():
a = numpy.ones(10000000)
a = a + a + a + a + a
a[0] = 3.0
def iterate():
sum = 0
a = numpy.ones(10000000)
for i in range(10000000):
sum += a[i]
return sum
total = 0.0
for i in range(10):
s = time.time()
add()
total += time.time() - s
print "add :", total / 10.0, "sec"
total = 0.0
for i in range(10):
s = time.time()
iterate()
total += time.time() - s
print "iterate :", total / 10.0, "sec"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment