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

tismer at codespeak.net tismer at codespeak.net
Wed Oct 12 16:02:25 CEST 2005


Author: tismer
Date: Wed Oct 12 16:02:24 2005
New Revision: 18477

Modified:
   pypy/dist/pypy/translator/goal/targetrpystonedalone.py
Log:
supports rpystone and richards, now.
moving on to use this for small-program benchmarking.

Modified: pypy/dist/pypy/translator/goal/targetrpystonedalone.py
==============================================================================
--- pypy/dist/pypy/translator/goal/targetrpystonedalone.py	(original)
+++ pypy/dist/pypy/translator/goal/targetrpystonedalone.py	Wed Oct 12 16:02:24 2005
@@ -1,11 +1,63 @@
 import os, sys
 from pypy.translator.test import rpystone
+from pypy.translator.goal import richards
+import pypy.interpreter.gateway # needed before sys, order of imports !!!
+from pypy.module.sys.version import svn_revision
 
 # __________  Entry point  __________
 
+VERSION = svn_revision()
+
+# note that we have %f but no length specifiers in RPython
+
+def pystones_main(loops):
+    benchtime, stones = rpystone.pystones(abs(loops))
+    s = '' # annotator happiness
+    if loops >= 0:
+        s = ("RPystone(%s) time for %d passes = %f" %
+             (VERSION, loops, benchtime) + '\n' + (
+             "This machine benchmarks at %f pystones/second" % stones))
+    os.write(1, s)
+
+def richards_main(iterations):
+    s = "Richards benchmark (RPython) starting...\n"
+    os.write(1, s)
+    result, startTime, endTime = richards.entry_point(iterations)
+    if not result:
+        os.write(2, "Incorrect results!\n")
+        return
+    os.write(1, "finished.\n")
+    total_s = endTime - startTime
+    avg = total_s * 1000 / iterations
+    os.write(1, "Total time for %d iterations: %f secs\n" %(iterations, total_s))
+    os.write(1, "Average time per iteration: %f ms\n" %(avg))
+
+DEF_PYSTONE = 10000000
+DEF_RICHARDS = 1000
+
 def entry_point(argv):
-    count = rpystone.pystones(20000000)
-    return count
+    proc = pystones_main
+    default = DEF_PYSTONE
+    n = 0
+    for s in argv[1:]:
+        s = s.lower()
+        if 'pystone'.startswith(s):
+            proc = pystones_main
+            default = DEF_PYSTONE
+        elif 'richards'.startswith(s):
+            proc = richards_main
+            default = DEF_RICHARDS
+        else:
+            try:
+                n = abs(int(s))
+            except ValueError:
+                os.write(2, '%s is neither a valid option (pystone, richards)'
+                            ' nor an integer\n')
+                return 1
+    if not n:
+        n = default
+    proc(n)
+    return 0
 
 # _____ Define and setup target ___
 



More information about the Pypy-commit mailing list