Created
December 16, 2011 06:44
-
-
Save iizukak/1484837 to your computer and use it in GitHub Desktop.
Benchmark for PyPy's numpypy
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
#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