[pypy-svn] r39709 - pypy/dist/pypy/translator/benchmark
mwh at codespeak.net
mwh at codespeak.net
Fri Mar 2 16:38:52 CET 2007
Author: mwh
Date: Fri Mar 2 16:38:48 2007
New Revision: 39709
Modified:
pypy/dist/pypy/translator/benchmark/bench-custom.py
pypy/dist/pypy/translator/benchmark/benchmarks.py
pypy/dist/pypy/translator/benchmark/result.py
Log:
allow benchmarks to indicate that they failed.
Modified: pypy/dist/pypy/translator/benchmark/bench-custom.py
==============================================================================
--- pypy/dist/pypy/translator/benchmark/bench-custom.py (original)
+++ pypy/dist/pypy/translator/benchmark/bench-custom.py Fri Mar 2 16:38:48 2007
@@ -40,7 +40,7 @@
for i in range(int(options.runcount)):
for exe in exes:
for b in benchmarks:
- benchmark_result.result(exe).run_benchmark(b, verbose=True)
+ benchmark_result.result(exe, allowcreate=True).run_benchmark(b, verbose=True)
pickle.dump(benchmark_result, open(options.picklefile, 'wb'))
Modified: pypy/dist/pypy/translator/benchmark/benchmarks.py
==============================================================================
--- pypy/dist/pypy/translator/benchmark/benchmarks.py (original)
+++ pypy/dist/pypy/translator/benchmark/benchmarks.py Fri Mar 2 16:38:48 2007
@@ -1,5 +1,8 @@
import os, sys, time, pickle, re, py
+class BenchmarkFailed(Exception):
+ pass
+
PYSTONE_CMD = 'from test import pystone;pystone.main(%s)'
PYSTONE_PATTERN = 'This machine benchmarks at'
PYSTONE_ASCENDING_GOOD = True
@@ -13,17 +16,20 @@
if line.startswith(pattern):
break
else:
- print repr(txt)
- print 'warning: this is not valid output'
- return 99999.0
+ raise BenchmarkFailed
return float(line.split()[len(pattern.split())])
class Benchmark(object):
def __init__(self, name, runner, asc_good, units):
self.name = name
- self.run = runner
+ self._run = runner
self.asc_good = asc_good
self.units = units
+ def run(self, exe):
+ try:
+ return self._run(exe)
+ except BenchmarkFailed:
+ return '-FAILED-'
def run_cmd(cmd):
#print "running", cmd
@@ -47,15 +53,14 @@
def run_translate(executable='/usr/local/bin/python'):
translate = py.magic.autopath().dirpath().dirpath().join('goal').join('translate.py')
- argstr = 'sh -c "time %s %s --text --batch --backendopt --no-compile targetrpystonedalone.py > /dev/null 2>/dev/null" 2>&1 | grep real'
- cmd = argstr%(executable, translate)
- txt = run_cmd(cmd)
- m = re.match('real\s+(?P<mins>\\d+)m(?P<secs>\\d+\\.\\d+)s', txt)
- if not m:
- print repr(txt)
- print 'ow'
- return 99999.0
- return 1000*(float(m.group('mins'))*60 + float(m.group('secs')))
+ target = py.magic.autopath().dirpath().dirpath().join('goal').join('targetrpystonedalone.py')
+ argstr = '%s %s --text --batch --backendopt --no-compile %s > /dev/null 2> /dev/null'
+ T = time.time()
+ status = os.system(argstr%(executable, translate, target))
+ r = time.time() - T
+ if status:
+ raise BenchmarkFailed(status)
+ return r
BENCHMARKS = [Benchmark('richards', run_richards, RICHARDS_ASCENDING_GOOD, 'ms'),
Benchmark('pystone', run_pystone, PYSTONE_ASCENDING_GOOD, ''),
Modified: pypy/dist/pypy/translator/benchmark/result.py
==============================================================================
--- pypy/dist/pypy/translator/benchmark/result.py (original)
+++ pypy/dist/pypy/translator/benchmark/result.py Fri Mar 2 16:38:48 2007
@@ -12,8 +12,8 @@
self.benchmarks = {}
self.max_results = max_results
- def result(self, exe):
- if exe in self.benchmarks:
+ def result(self, exe, allowcreate=False):
+ if exe in self.benchmarks or not allowcreate:
return self.benchmarks[exe]
else:
r = self.benchmarks[exe] = BenchmarkResult(exe, self.max_results)
@@ -89,6 +89,9 @@
new_result = benchmark.run(self.exe_name)
if verbose:
print new_result
+ self.run_counts[benchmark.name] = self.run_counts.get(benchmark.name, 0) + 1
+ if new_result == '-FAILED-':
+ return
self.benchmarks.setdefault(benchmark.name, []).append(new_result)
if benchmark.name in self.best_benchmarks:
old_result = self.best_benchmarks[benchmark.name]
@@ -97,7 +100,6 @@
else:
new_result = min(new_result, old_result)
self.best_benchmarks[benchmark.name] = new_result
- self.run_counts[benchmark.name] = self.run_counts.get(benchmark.name, 0) + 1
def getstat(self, *args):
# oh for supplied-p!
More information about the pypy-svn
mailing list