[pypy-svn] r76045 - pypy/branch/interplevel-array/pypy/module/array/test

hakanardo at codespeak.net hakanardo at codespeak.net
Thu Jul 8 19:04:09 CEST 2010


Author: hakanardo
Date: Thu Jul  8 19:04:08 2010
New Revision: 76045

Added:
   pypy/branch/interplevel-array/pypy/module/array/test/sum.c
   pypy/branch/interplevel-array/pypy/module/array/test/sumtst.c
Modified:
   pypy/branch/interplevel-array/pypy/module/array/test/Makefile
   pypy/branch/interplevel-array/pypy/module/array/test/inttst.py
   pypy/branch/interplevel-array/pypy/module/array/test/sumtst.py
Log:
performace tests

Modified: pypy/branch/interplevel-array/pypy/module/array/test/Makefile
==============================================================================
--- pypy/branch/interplevel-array/pypy/module/array/test/Makefile	(original)
+++ pypy/branch/interplevel-array/pypy/module/array/test/Makefile	Thu Jul  8 19:04:08 2010
@@ -4,3 +4,5 @@
 	gcc -o $@ $^
 loop: loop.o
 	gcc -o $@ $^
+sum: sumtst.o sum.o
+	gcc -o $@ $^	
\ No newline at end of file

Modified: pypy/branch/interplevel-array/pypy/module/array/test/inttst.py
==============================================================================
--- pypy/branch/interplevel-array/pypy/module/array/test/inttst.py	(original)
+++ pypy/branch/interplevel-array/pypy/module/array/test/inttst.py	Thu Jul  8 19:04:08 2010
@@ -1,19 +1,26 @@
 #!/usr/bin/python
 from time import time
 
-from array import array
-#img=array('B',(0,)*640*480);
-#intimg=array('I',(0,)*640*480);
-img=array(640*480);
-intimg=array(640*480);
+from array import array #, simple_array
 
-def f():
+def f(img, intimg):
     l=0
-    for i in xrange(640,640*480):
+    i=640    
+    while i<640*480:
         l+=img[i]
         intimg[i]=intimg[i-640]+l
+        i+=1
+    return l
 
 
+
+if True:
+    img=array('d','\x00'*640*480*8)
+    intimg=array('d','\x00'*640*480*8)
+else:
+    img=simple_array(640*480)
+    intimg=simple_array(640*480)
+
 start=time()
-for l in range(500): f()
+for l in range(500): f(img, intimg)
 print time()-start

Added: pypy/branch/interplevel-array/pypy/module/array/test/sum.c
==============================================================================
--- (empty file)
+++ pypy/branch/interplevel-array/pypy/module/array/test/sum.c	Thu Jul  8 19:04:08 2010
@@ -0,0 +1,7 @@
+double sum(double *img) {
+  int l=0;
+  for (int i=0; i<640*480; i++) {
+    l+=img[i];
+  }
+  return l;
+}

Added: pypy/branch/interplevel-array/pypy/module/array/test/sumtst.c
==============================================================================
--- (empty file)
+++ pypy/branch/interplevel-array/pypy/module/array/test/sumtst.c	Thu Jul  8 19:04:08 2010
@@ -0,0 +1,8 @@
+
+double sum(double *img);
+
+void main() {
+  double *img=malloc(640*480*4*sizeof(double));
+  int sa=0;
+  for (int l=0; l<500; l++) sum(img);
+}    

Modified: pypy/branch/interplevel-array/pypy/module/array/test/sumtst.py
==============================================================================
--- pypy/branch/interplevel-array/pypy/module/array/test/sumtst.py	(original)
+++ pypy/branch/interplevel-array/pypy/module/array/test/sumtst.py	Thu Jul  8 19:04:08 2010
@@ -1,8 +1,8 @@
 #!/usr/bin/python
-from array import array
+from array import array, simple_array
 
-img=array(640*480);
-def f():
+#img=array('d',(0,)*640*480);
+def f(img):
     l=0
     i=0;
     while i<640*480:
@@ -10,6 +10,14 @@
         i+=1
     return l
 
+if False:
+    img=array('d', '\x00'*640*480*8)
+else:
+    img=simple_array(640*480)
+    
+for l in range(500): f(img)
+#print f(img)
 
-#for l in range(500): f()
-print f()
+#           C          pypy-simple pypy        cpython
+# sumtst:   0m0.630s   0m0.659s    0m9.185s    0m33.447s
+# intimg:   0m0.646s   0m1.404s    0m26.850s   1m0.279s



More information about the Pypy-commit mailing list