[pypy-svn] r70675 - in pypy/benchmarks: . shootout unladen_swallow/performance
fijal at codespeak.net
fijal at codespeak.net
Mon Jan 18 13:17:25 CET 2010
Author: fijal
Date: Mon Jan 18 13:17:25 2010
New Revision: 70675
Added:
pypy/benchmarks/benchmarks.py (contents, props changed)
pypy/benchmarks/shootout/__init__.py (contents, props changed)
pypy/benchmarks/shootout/setup.py (contents, props changed)
pypy/benchmarks/shootout/util.py (contents, props changed)
Removed:
pypy/benchmarks/unladen_swallow/performance/__init__.py
Modified:
pypy/benchmarks/runner.py
pypy/benchmarks/shootout/float.py (contents, props changed)
Log:
Start adding benchmarks. Float benchmark comes first
Added: pypy/benchmarks/benchmarks.py
==============================================================================
--- (empty file)
+++ pypy/benchmarks/benchmarks.py Mon Jan 18 13:17:25 2010
@@ -0,0 +1,10 @@
+
+import py
+from unladen_swallow.perf import SimpleBenchmark, MeasureGeneric
+
+def MeasureFloat(python, options):
+ bm_path = str(py.path.local(__file__).dirpath().join("shootout", "float.py"))
+ return MeasureGeneric(python, options, bm_path)
+
+def BM_float(*args, **kwds):
+ return SimpleBenchmark(MeasureFloat, *args, **kwds)
Modified: pypy/benchmarks/runner.py
==============================================================================
--- pypy/benchmarks/runner.py (original)
+++ pypy/benchmarks/runner.py Mon Jan 18 13:17:25 2010
@@ -5,13 +5,16 @@
import os
import json
import sys
-from unladen_swallow.perf import main, BENCH_FUNCS
+from unladen_swallow.perf import main, BENCH_FUNCS, _FindAllBenchmarks
+import benchmarks
-def run_and_store(benchmarks, result_filename, pypy_c_path, revision=0):
- results = main(['-f', '-b', ','.join(benchmarks),
+def run_and_store(benchmark_set, result_filename, pypy_c_path, revision=0):
+ funcs = BENCH_FUNCS.copy()
+ funcs.update(_FindAllBenchmarks(benchmarks.__dict__))
+ results = main(['-f', '-b', ','.join(benchmark_set),
'--inherit_env=PATH',
'--no_charts', sys.executable, pypy_c_path],
- BENCH_FUNCS)
+ funcs)
f = open(str(result_filename), "w")
res = [(name, result.__class__.__name__, result.__dict__)
for name, result in results]
@@ -23,5 +26,5 @@
if __name__ == '__main__':
BENCHMARK_SET = ['richards', 'slowspitfire', 'django', 'spambayes',
- 'rietveld', 'html5lib', 'ai']
+ 'rietveld', 'html5lib', 'ai', 'float']
run_and_store(BENCHMARK_SET, sys.argv[1], sys.argv[2], int(sys.argv[3]))
Added: pypy/benchmarks/shootout/__init__.py
==============================================================================
Modified: pypy/benchmarks/shootout/float.py
==============================================================================
--- pypy/benchmarks/shootout/float.py (original)
+++ pypy/benchmarks/shootout/float.py Mon Jan 18 13:17:25 2010
@@ -1,8 +1,9 @@
+#!/usr/bin/env python
# -*- coding: utf-8 -*-
from math import sin, cos, sqrt
-import sys
-
-NUMBER_OF_RUNS = int(sys.argv[1])
+import util
+import optparse
+import time
class Point(object):
@@ -44,15 +45,24 @@
p.normalize()
return maximize(points)
-def main():
- if len(sys.argv) == 1:
- n = 100000
- else:
- n = int(sys.argv[1])
- for i in xrange(NUMBER_OF_RUNS):
- o = benchmark(n)
- print o
-
-if __name__ == '__main__':
- for i in range(int(sys.argv[2])):
- main()
+POINTS = 100000
+
+def main(arg):
+ # XXX warmup
+
+ times = []
+ for i in xrange(arg):
+ t0 = time.time()
+ o = benchmark(POINTS)
+ 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()
+
+ util.run_benchmark(options, options.num_runs, main)
Added: pypy/benchmarks/shootout/setup.py
==============================================================================
--- (empty file)
+++ pypy/benchmarks/shootout/setup.py Mon Jan 18 13:17:25 2010
@@ -0,0 +1,4 @@
+
+# a bit dirty directory setup
+import sys
+sys.path.insert(0, '..')
Added: pypy/benchmarks/shootout/util.py
==============================================================================
--- (empty file)
+++ pypy/benchmarks/shootout/util.py Mon Jan 18 13:17:25 2010
@@ -0,0 +1 @@
+link ../unladen_swallow/performance/util.py
\ No newline at end of file
More information about the Pypy-commit
mailing list