Debian Codegraph @

pypy/tool/bench/pypyresult.py

raw symbols SCIP
1 import py
2
3 class ResultDB(object):
4 def __init__(self):
5 self.benchmarks = []
6
7 def parsepickle(self, path):
8 f = path.open("rb")
9 id2numrun = py.std.pickle.load(f)
10 id2bestspeed = py.std.pickle.load(f)
11 f.close()
12 for id in id2numrun:
13 besttime = id2bestspeed[id]
14 numruns = id2numrun[id]
15 print id
16 bench = BenchResult(id, besttime, numruns)
17 self.benchmarks.append(bench)
18
19 def getbenchmarks(self, name=None):
20 l = []
21 for bench in self.benchmarks:
22 if name is not None and name != bench.name:
23 continue
24 l.append(bench)
25 return l
26
27 class BenchResult(object):
28 def __init__(self, id, besttime, numruns):
29 self._id = id
30 if id.startswith("./"):
31 id = id[2:]
32 if id.startswith("pypy"):
33 parts = id.rsplit("_", 1)
34 self.executable = parts[0]
35 self.name = parts[1]
36 parts = self.executable.split("-")
37 self.backend = parts[1]
38 try:
39 self.revision = int(parts[2])
40 except ValueError:
41 self.revision = None
42 else: # presumably cpython
43 version, name = id.split("_", 1)
44 self.name = name
45 self.backend = None
46 self.revision = version
47 self.executable = "cpython"
48 self.besttime = besttime
49 self.numruns = numruns
50 def __repr__(self):
51 return "<BenchResult %r>" %(self._id, )
52
53
54 if __name__ == "__main__":
55 x = py.path.local(__file__).dirpath("bench-unix.benchmark_result")
56 db = ResultDB()
57 db.parsepickle(x)
58