[pypy-svn] r17573 - pypy/dist/pypy/translator/goal

tismer at codespeak.net tismer at codespeak.net
Thu Sep 15 04:30:38 CEST 2005


Author: tismer
Date: Thu Sep 15 04:30:37 2005
New Revision: 17573

Added:
   pypy/dist/pypy/translator/goal/bench-windows.py   (contents, props changed)
Log:
automated benchmarking under windows a little bit.

Here the current results:

executable           abs.richards   abs.pystone   rel.richards   rel.pystone
pypy-c-17439           35871 ms         634.714      42.1           62.8
pypy-c-17512           46878 ms         665.326      55.0           59.9
pypy-c-17516           38956 ms         707.266      45.7           56.3
pypy-c-17545-intern    35369 ms         763.616      41.5           52.2
pypy-c-17572           37032 ms         763.531      43.4           52.2
python 2.3.3             853 ms       39831.500       1.0            1.0

As a current result, inlining appears not to be a candidate worth optimizing, yet.

Added: pypy/dist/pypy/translator/goal/bench-windows.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/goal/bench-windows.py	Thu Sep 15 04:30:37 2005
@@ -0,0 +1,70 @@
+# benchmarks on a windows machine.
+# to be executed in the goal folder,
+# where a couple of .exe files is expected.
+
+import os, sys
+
+PYSTONE_CMD = 'from test import pystone;pystone.main(%s)'
+PYSTONE_PATTERN = 'This machine benchmarks at'
+RICHARDS_CMD = 'from richards import *;Richards.iterations=%d;main()'
+RICHARDS_PATTERN = 'Average time for iterations:'
+
+def get_result(txt, pattern):
+    for line in txt.split('\n'):
+        if line.startswith(pattern):
+            break
+    else:
+        raise ValueError, 'this is no valid output'
+    return float(line.split()[len(pattern.split())])
+
+def run_cmd(cmd):
+    print "running", cmd
+    pipe = os.popen(cmd + ' 2>&1')
+    result = pipe.read()
+    print "done"
+    return result
+
+def run_pystone(executable='python', n=0):
+    argstr = PYSTONE_CMD % (str(n) and n or '')
+    txt = run_cmd('%s -c "%s"' % (executable, argstr))
+    return get_result(txt, PYSTONE_PATTERN)
+
+def run_richards(executable='python', n=10):
+    argstr = RICHARDS_CMD % n
+    txt = run_cmd('%s -c "%s"' % (executable, argstr))
+    return get_result(txt, RICHARDS_PATTERN)
+
+def get_executables():
+    exes = [name for name in os.listdir('.') if name.endswith('.exe')]
+    exes.sort()
+    return exes
+
+LAYOUT = '''
+executable           abs.richards   abs.pystone   rel.richards   rel.pystone
+pypy-c-17439           40929 ms         637.274      47.8           56.6
+pypy-c-17512           46105 ms         658.1        53.9           54.8
+pypy-current           33937 ms         698.415      39.6           51.7
+python 2.3.3             856 ms       36081.6         1.0            1.0
+'''
+
+HEADLINE = '''\
+executable           abs.richards   abs.pystone   rel.richards   rel.pystone'''
+FMT = '''\
+%-20s   '''          +  '%5d ms       %9.3f     ' + '%5.1f          %5.1f'
+
+def main():
+    print 'getting the richards reference'
+    ref_rich = run_richards()
+    print 'getting the pystone reference'
+    ref_stone = run_pystone()
+    res = []
+    for exe in get_executables():
+        exename = os.path.splitext(exe)[0]
+        res.append( (exename, run_richards(exe, 1), run_pystone(exe, 2000)) )
+    res.append( ('python %s' % sys.version.split()[0], ref_rich, ref_stone) )
+    print HEADLINE
+    for exe, rich, stone in res:
+        print FMT % (exe, rich, stone, rich / ref_rich, ref_stone / stone)
+
+if __name__ == '__main__':
+    main()



More information about the Pypy-commit mailing list