[pypy-svn] r39895 - in pypy/dist/pypy/tool/bench: . test
hpk at codespeak.net
hpk at codespeak.net
Sun Mar 4 16:13:27 CET 2007
Author: hpk
Date: Sun Mar 4 16:13:25 2007
New Revision: 39895
Added:
pypy/dist/pypy/tool/bench/pypyresult.py (contents, props changed)
pypy/dist/pypy/tool/bench/test/test_pypyresult.py (contents, props changed)
Log:
added the start of pypy benchmark result parsing and tests
Added: pypy/dist/pypy/tool/bench/pypyresult.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/tool/bench/pypyresult.py Sun Mar 4 16:13:25 2007
@@ -0,0 +1,37 @@
+import py
+
+class ResultDB(object):
+ def __init__(self):
+ self.benchmarks = []
+
+ def parsepickle(self, path):
+ f = path.open("rb")
+ id2numrun = py.std.pickle.load(f)
+ id2bestspeed = py.std.pickle.load(f)
+ f.close()
+ for id in id2numrun:
+ besttime = id2bestspeed[id]
+ numruns = id2numrun[id]
+ bench = BenchResult(id, besttime, numruns)
+ self.benchmarks.append(bench)
+
+ def getbenchmarks(self, name=None):
+ l = []
+ for bench in self.benchmarks:
+ if name is not None and name != bench.name:
+ continue
+ l.append(bench)
+ return l
+
+class BenchResult(object):
+ def __init__(self, id, besttime, numruns):
+ self._id = id
+ if id.startswith("./"):
+ id = id[2:]
+ parts = id.split("-")
+ self.name = parts.pop(-1)
+ self.backend = parts[1]
+ self.revision = int(parts[2])
+ self.executable = "-".join(parts)
+ self.besttime = besttime
+ self.numruns = numruns
Added: pypy/dist/pypy/tool/bench/test/test_pypyresult.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/tool/bench/test/test_pypyresult.py Sun Mar 4 16:13:25 2007
@@ -0,0 +1,34 @@
+
+import py
+
+from pypy.tool.bench.pypyresult import ResultDB
+import pickle
+
+def setup_module(mod):
+ mod.tmpdir = py.test.ensuretemp(__name__)
+
+def gettestpickle(cache=[]):
+ if cache:
+ return cache[0]
+ pp = tmpdir.join("testpickle")
+ f = pp.open("wb")
+ pickle.dump({'./pypy-llvm-39474-faassen-c_richards': 5}, f)
+ pickle.dump({'./pypy-llvm-39474-faassen-c_richards': 42.0}, f)
+ f.close()
+ cache.append(pp)
+ return pp
+
+def test_unpickle():
+ pp = gettestpickle()
+ db = ResultDB()
+ db.parsepickle(pp)
+ assert len(db.benchmarks) == 1
+ l = db.getbenchmarks(name="c_richards")
+ assert len(l) == 1
+ bench = l[0]
+ assert bench.executable == "pypy-llvm-39474-faassen"
+ assert bench.name == "c_richards"
+ assert bench.revision == 39474
+ assert bench.numruns == 5
+ assert bench.besttime == 42.0
+
More information about the Pypy-commit
mailing list