[pypy-svn] r59296 - in pypy/build/benchmem: . benchmark

fijal at codespeak.net fijal at codespeak.net
Tue Oct 21 13:18:47 CEST 2008


Author: fijal
Date: Tue Oct 21 13:18:46 2008
New Revision: 59296

Modified:
   pypy/build/benchmem/benchmark/appprofiles.py
   pypy/build/benchmem/report_graphic.py
   pypy/build/benchmem/runbench.py
Log:
* Some adaptations of numbers, to actually showcase what we're after
* Add a very nasty cycle based benchmark
* Show all graphs by default


Modified: pypy/build/benchmem/benchmark/appprofiles.py
==============================================================================
--- pypy/build/benchmem/benchmark/appprofiles.py	(original)
+++ pypy/build/benchmem/benchmark/appprofiles.py	Tue Oct 21 13:18:46 2008
@@ -21,15 +21,15 @@
         return [float(first), second]
 
 def bench_allocate_and_throw_away(iter1, iter2):
-    for i in range(iter1):
+    for i in range(iter2):
         next = None
-        for j in range(iter2):
+        for j in range(iter1):
             next = one(j, j, next)
 
 def bench_allocate_constant_number(iter1, iter2):
-    l = [None] * iter1
+    l = [None] * iter2
     for i in range(iter1 * iter2):
-        l[i % iter1] = one(i, i, i)
+        l[i % iter2] = one(i, i, i)
 
 def bench_allocate_couple(iter1, iter2):
     alive = [None] * iter2
@@ -39,8 +39,34 @@
             next = one(j, j, next)
         alive[i] = one(i, i, i)
 
+def bench_cpython_nasty(iter1, iter2):
+    # we create some cycles here, to expose cpython's dealing
+    # with reference cycles
+    def create_cycle():
+        class A(object):
+            def __init__(self, prev, next):
+                self.prev = prev
+                self.next = next
+
+        a1 = A(None, None)
+        a2 = A(a1, None)
+        a3 = A(a2, a1)
+        a2.next = a3
+        a1.next = a2
+        a1.prev = a3
+
+    class B(object):
+        def __init__(self, next):
+            self.next = next
+            self.cycle = create_cycle()
+
+    for i in range(iter2):
+        next = None
+        for i in range(iter1/3):
+            next = B(next)
 
 if __name__ == '__main__':
-    bench_allocate_and_throw_away(100000, 3)
-    bench_allocate_couple(100000, 3)
-    bench_allocate_constant_number(100000, 3)
+    bench_allocate_and_throw_away(10000, 3)
+    bench_allocate_couple(10000, 3)
+    bench_allocate_constant_number(10000, 3)
+    bench_cpython_nasty(10000, 3)

Modified: pypy/build/benchmem/report_graphic.py
==============================================================================
--- pypy/build/benchmem/report_graphic.py	(original)
+++ pypy/build/benchmem/report_graphic.py	Tue Oct 21 13:18:46 2008
@@ -13,13 +13,13 @@
     #     right now, just adjust the number below. Also if we want to
     #     generate postscript or whatever we would need to do this for
     #     all anyway
-    name, results = resultset.getname2results()[0]
-    for result in results:
-        lgt = len(result.snapshots)
-        x = [float(i)/lgt for i in range(lgt)]
-        y = [snapshot.private for snapshot in result.snapshots]
-        plot(x, y)
-    show()
+    for name, results in resultset.getname2results():
+        for result in results:
+            lgt = len(result.snapshots)
+            x = [float(i)/lgt for i in range(lgt)]
+            y = [snapshot.private for snapshot in result.snapshots]
+            plot(x, y)
+        show()
 
 if __name__ == '__main__':
     if len(sys.argv) > 3:

Modified: pypy/build/benchmem/runbench.py
==============================================================================
--- pypy/build/benchmem/runbench.py	(original)
+++ pypy/build/benchmem/runbench.py	Tue Oct 21 13:18:46 2008
@@ -177,7 +177,7 @@
             #sys.stdout.flush()
 
 class BenchRunnerAppProfiles(BenchRunner):
-    ITER2 = 100000
+    ITER2 = 10
 
     def __init__(self, *args):
         BenchRunner.__init__(self, *args)
@@ -208,7 +208,7 @@
         self.interact_with_child(rec, stdout, stdin)
 
     def makebench(self, name):
-        arglist = (int(self.options.numiter)/3000, self.ITER2)
+        arglist = (int(self.options.numiter), self.ITER2)
         source = py.code.Source(self.benchpath.read(), """
             import gc
             def write(c):



More information about the Pypy-commit mailing list