[pypy-commit] pypy default: update dot bench script

bdkearns noreply at buildbot.pypy.org
Fri Feb 28 00:58:37 CET 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r69529:dd054f91e29d
Date: 2014-02-27 15:57 -0800
http://bitbucket.org/pypy/pypy/changeset/dd054f91e29d/

Log:	update dot bench script

diff --git a/pypy/module/micronumpy/bench/dot.py b/pypy/module/micronumpy/bench/dot.py
--- a/pypy/module/micronumpy/bench/dot.py
+++ b/pypy/module/micronumpy/bench/dot.py
@@ -1,28 +1,32 @@
+import sys
 import time
 
 try:
-    import numpypy
+    import numpypy as numpy
 except ImportError:
-    pass
+    import numpy
 
-import numpy
-
-def get_matrix():
+def get_matrix(n):
     import random
-    n = 502
     x = numpy.zeros((n,n), dtype=numpy.float64)
     for i in range(n):
         for j in range(n):
             x[i][j] = random.random()
     return x
 
-def main():
-    x = get_matrix()
-    y = get_matrix()
+def main(n, r):
+    x = get_matrix(n)
+    y = get_matrix(n)
     a = time.time()
-    #z = numpy.dot(x, y)  # uses numpy possibly-blas-lib dot
-    z = numpy.core.multiarray.dot(x, y)  # uses strictly numpy C dot
+    for _ in xrange(r):
+        #z = numpy.dot(x, y)  # uses numpy possibly-blas-lib dot
+        z = numpy.core.multiarray.dot(x, y)  # uses strictly numpy C dot
     b = time.time()
-    print '%.2f seconds' % (b-a)
+    print '%d runs, %.2f seconds' % (r, b-a)
 
-main()
+n = int(sys.argv[1])
+try:
+    r = int(sys.argv[2])
+except IndexError:
+    r = 1
+main(n, r)
diff --git a/pypy/module/micronumpy/iterators.py b/pypy/module/micronumpy/iterators.py
--- a/pypy/module/micronumpy/iterators.py
+++ b/pypy/module/micronumpy/iterators.py
@@ -115,7 +115,7 @@
         if step == 0:
             return
         self.index += step
-        for i in range(self.ndim_m1, -1, -1):
+        for i in xrange(self.ndim_m1, -1, -1):
             if self.indices[i] < (self.shape_m1[i] + 1) - step:
                 self.indices[i] += step
                 self.offset += self.strides[i] * step


More information about the pypy-commit mailing list