[pypy-svn] r70681 - in pypy/benchmarks: . shootout

fijal at codespeak.net fijal at codespeak.net
Mon Jan 18 14:13:25 CET 2010


Author: fijal
Date: Mon Jan 18 14:13:24 2010
New Revision: 70681

Modified:
   pypy/benchmarks/benchmarks.py
   pypy/benchmarks/runner.py
   pypy/benchmarks/shootout/meteor-contest.py
   pypy/benchmarks/shootout/nbody_modified.py
Log:
Add meteor-contest, kill a bit of unnecessary prints


Modified: pypy/benchmarks/benchmarks.py
==============================================================================
--- pypy/benchmarks/benchmarks.py	(original)
+++ pypy/benchmarks/benchmarks.py	Mon Jan 18 14:13:24 2010
@@ -17,5 +17,5 @@
 
     d[BM.func_name] = BM
 
-for name in ['float', 'nbody_modified']:
+for name in ['float', 'nbody_modified', 'meteor-contest']:
     _register_new_bm(name, globals())

Modified: pypy/benchmarks/runner.py
==============================================================================
--- pypy/benchmarks/runner.py	(original)
+++ pypy/benchmarks/runner.py	Mon Jan 18 14:13:24 2010
@@ -25,7 +25,8 @@
     f.close()
 
 BENCHMARK_SET = ['richards', 'slowspitfire', 'django', 'spambayes',
-                 'rietveld', 'html5lib', 'ai', 'float', 'nbody_modified']
+                 'rietveld', 'html5lib', 'ai']
+BENCHMARK_SET += perf._FindAllBenchmarks(benchmarks.__dict__).keys()
 
 class WrongBenchmark(Exception):
     pass

Modified: pypy/benchmarks/shootout/meteor-contest.py
==============================================================================
--- pypy/benchmarks/shootout/meteor-contest.py	(original)
+++ pypy/benchmarks/shootout/meteor-contest.py	Mon Jan 18 14:13:24 2010
@@ -4,7 +4,10 @@
 #
 # contributed by Daniel Nanz, 2008-08-21
 
+import optparse
+import util
 import sys
+import time
 from bisect import bisect
 
 w, h = 5, 10
@@ -130,16 +133,29 @@
             return
     return
 
-def main(n):
+SOLVE_ARG = 60
 
-    free = frozenset(xrange(len(board)))
-    curr_board = [-1] * len(board)
-    pieces_left = range(len(pieces))
-    solutions = []
-    solve(n, 0, free, curr_board, pieces_left, solutions)
-    print len(solutions),  'solutions found\n'
-    for i in (0, -1): print_board(solutions[i])
+def main(n):
+    times = []
+    for i in range(n):
+        t0 = time.time()
+        free = frozenset(xrange(len(board)))
+        curr_board = [-1] * len(board)
+        pieces_left = range(len(pieces))
+        solutions = []
+        solve(SOLVE_ARG, 0, free, curr_board, pieces_left, solutions)
+        #print len(solutions),  'solutions found\n'
+        #for i in (0, -1): print_board(solutions[i])
+        tk = time.time()
+        times.append(tk - t0)
+    return times
+    
+if __name__ == "__main__":
+    parser = optparse.OptionParser(
+        usage="%prog [options]",
+        description="Test the performance of the Float benchmark")
+    util.add_standard_options_to(parser)
+    options, args = parser.parse_args()
 
-for i in range(int(sys.argv[2])):
-    main(int(sys.argv[1]))
+    util.run_benchmark(options, options.num_runs, main)
 

Modified: pypy/benchmarks/shootout/nbody_modified.py
==============================================================================
--- pypy/benchmarks/shootout/nbody_modified.py	(original)
+++ pypy/benchmarks/shootout/nbody_modified.py	Mon Jan 18 14:13:24 2010
@@ -95,8 +95,6 @@
         e -= (m1 * m2) / ((dx * dx + dy * dy + dz * dz) ** 0.5)
     for (r, [vx, vy, vz], m) in bodies:
         e += m * (vx * vx + vy * vy + vz * vz) / 2.
-    print "%.9f" % e
-
 
 def offset_momentum(ref, bodies=SYSTEM, px=0.0, py=0.0, pz=0.0):
 



More information about the Pypy-commit mailing list