[pypy-commit] benchmarks default: (arigo, cfbolz)

cfbolz noreply at buildbot.pypy.org
Tue Dec 9 18:59:55 CET 2014


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: 
Changeset: r291:ded8521a022d
Date: 2014-12-09 18:00 +0000
http://bitbucket.org/pypy/benchmarks/changeset/ded8521a022d/

Log:	(arigo, cfbolz)

	add a pypy_interp benchmark that runs a loop in the pypy interpreter

diff --git a/benchmarks.py b/benchmarks.py
--- a/benchmarks.py
+++ b/benchmarks.py
@@ -82,7 +82,7 @@
              'spectral-norm', 'chaos', 'telco', 'go', 'pyflate-fast',
              'raytrace-simple', 'crypto_pyaes', 'bm_mako', 'bm_chameleon',
              'json_bench', 'pidigits', 'hexiom2', 'eparse', 'deltablue',
-             'bm_dulwich_log', 'bm_krakatau', 'bm_mdp']:
+             'bm_dulwich_log', 'bm_krakatau', 'bm_mdp', 'pypy_interp']:
     _register_new_bm(name, name, globals(), **opts.get(name, {}))
 
 for name in ['names', 'iteration', 'tcp', 'pb', ]:#'web']:#, 'accepts']:
diff --git a/own/pypy_interp.py b/own/pypy_interp.py
new file mode 100644
--- /dev/null
+++ b/own/pypy_interp.py
@@ -0,0 +1,45 @@
+import sys, os, cStringIO
+import time
+import util, optparse
+
+pardir = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
+pypypath = os.path.join(pardir, 'lib', 'pypy')
+sys.path.insert(0, pypypath)
+
+from pypy.tool.pytest.objspace import gettestobjspace
+
+def bench(space):
+    w_l = space.appexec([], """():
+        class A(object):
+            def __init__(self, x):
+                self.x = x
+        glob_a = A(1)
+        l = []
+        a, b = 1, 1
+        for i in range(100):
+            l.append((i, a, str(i), float(i), {i: a}, A(b), glob_a.x))
+            a, b = b, a + b
+        return l
+    """)
+
+def main(n):
+    l = []
+    space = gettestobjspace()
+    # warmup
+    bench(space)
+    bench(space)
+    for i in range(n):
+        t0 = time.time()
+        bench(space)
+        time_elapsed = time.time() - t0
+        l.append(time_elapsed)
+    return l
+
+if __name__ == "__main__":
+    parser = optparse.OptionParser(
+        usage="%prog [options]",
+        description="Test the performance of the pypy-interp benchmark")
+    util.add_standard_options_to(parser)
+    options, args = parser.parse_args()
+
+    util.run_benchmark(options, options.num_runs, main)


More information about the pypy-commit mailing list