[pypy-svn] r70680 - in pypy/benchmarks: . shootout
fijal at codespeak.net
fijal at codespeak.net
Mon Jan 18 14:03:19 CET 2010
Author: fijal
Date: Mon Jan 18 14:03:18 2010
New Revision: 70680
Added:
pypy/benchmarks/shootout/nbody_modified.py
- copied, changed from r70675, pypy/benchmarks/shootout/nbody.py
Removed:
pypy/benchmarks/shootout/nbody.py
Modified:
pypy/benchmarks/benchmarks.py
pypy/benchmarks/runner.py
Log:
Add a 2.5 compatible version of nbody
Modified: pypy/benchmarks/benchmarks.py
==============================================================================
--- pypy/benchmarks/benchmarks.py (original)
+++ pypy/benchmarks/benchmarks.py Mon Jan 18 14:03:18 2010
@@ -2,10 +2,20 @@
import os
from unladen_swallow.perf import SimpleBenchmark, MeasureGeneric
-def MeasureFloat(python, options):
- bm_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
- 'shootout', 'float.py')
- return MeasureGeneric(python, options, bm_path)
+def relative(*args):
+ return os.path.join(os.path.dirname(os.path.abspath(__file__)), *args)
-def BM_float(*args, **kwds):
- return SimpleBenchmark(MeasureFloat, *args, **kwds)
+def _register_new_bm(name, d):
+ def Measure(python, options):
+ bm_path = relative('shootout', name + '.py')
+ return MeasureGeneric(python, options, bm_path)
+ Measure.func_name = 'Measure' + name.capitalize()
+
+ def BM(*args, **kwds):
+ return SimpleBenchmark(Measure, *args, **kwds)
+ BM.func_name = 'BM_' + name
+
+ d[BM.func_name] = BM
+
+for name in ['float', 'nbody_modified']:
+ _register_new_bm(name, globals())
Modified: pypy/benchmarks/runner.py
==============================================================================
--- pypy/benchmarks/runner.py (original)
+++ pypy/benchmarks/runner.py Mon Jan 18 14:03:18 2010
@@ -25,7 +25,7 @@
f.close()
BENCHMARK_SET = ['richards', 'slowspitfire', 'django', 'spambayes',
- 'rietveld', 'html5lib', 'ai', 'float']
+ 'rietveld', 'html5lib', 'ai', 'float', 'nbody_modified']
class WrongBenchmark(Exception):
pass
Copied: pypy/benchmarks/shootout/nbody_modified.py (from r70675, pypy/benchmarks/shootout/nbody.py)
==============================================================================
--- pypy/benchmarks/shootout/nbody.py (original)
+++ pypy/benchmarks/shootout/nbody_modified.py Mon Jan 18 14:03:18 2010
@@ -6,6 +6,9 @@
# modified by Tupteq, Fredrik Johansson, and Daniel Nanz
import sys
+import util
+import optparse
+import time
def combinations(l):
result = []
@@ -106,13 +109,27 @@
v[1] = py / m
v[2] = pz / m
+NUMBER_OF_ITERATIONS = 20000
def main(n, ref='sun'):
+ # XXX warmup
+
+ times = []
+ for i in range(n):
+ t0 = time.time()
+ offset_momentum(BODIES[ref])
+ report_energy()
+ advance(0.01, NUMBER_OF_ITERATIONS)
+ report_energy()
+ tk = time.time()
+ times.append(tk - t0)
+ return times
+
+if __name__ == "__main__":
+ parser = optparse.OptionParser(
+ usage="%prog [options]",
+ description="Test the performance of the 2.5 compatible nbody benchmark")
+ util.add_standard_options_to(parser)
+ options, args = parser.parse_args()
- offset_momentum(BODIES[ref])
- report_energy()
- advance(0.01, n)
- report_energy()
-
-for i in range(int(sys.argv[2])):
- main(int(sys.argv[1]))
+ util.run_benchmark(options, options.num_runs, main)
More information about the Pypy-commit
mailing list