[Python-checkins] benchmarks: Issue #19064: let perf.py decide which library path is required for which
antoine.pitrou
python-checkins at python.org
Mon Sep 23 21:37:18 CEST 2013
http://hg.python.org/benchmarks/rev/88b6ef9aa9e9
changeset: 207:88b6ef9aa9e9
user: Antoine Pitrou <solipsis at pitrou.net>
date: Mon Sep 23 21:35:13 2013 +0200
summary:
Issue #19064: let perf.py decide which library path is required for which interpreter
files:
perf.py | 42 +++++++++++++++++++++++++++++++++---------
1 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/perf.py b/perf.py
--- a/perf.py
+++ b/perf.py
@@ -87,10 +87,31 @@
info = logging.info
-if sys.version_info[0] == 2:
- ported_lib = 'lib'
-else:
- ported_lib = 'lib3'
+
+def ported_lib(python, _cache={}):
+ """Return the 3rd-party library path for the given Python interpreter.
+ *python* is the base command (as a list) to execute the interpreter.
+ """
+ key = tuple(python)
+ try:
+ return _cache[key]
+ except KeyError:
+ pass
+ code = """import sys; print(sys.version_info[0])"""
+ subproc = subprocess.Popen(python + ['-c', code],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ out, err = subproc.communicate()
+ if subproc.returncode != 0:
+ raise RuntimeError("Benchmark died: " + err)
+ major = int(out.strip())
+ if major == 2:
+ result = 'lib'
+ else:
+ result = 'lib3'
+ _cache[key] = result
+ return result
+
def avg(seq):
return sum(seq) / float(len(seq))
@@ -1272,8 +1293,10 @@
def Measure2to3(python, options):
- fast_target = Relative(ported_lib+"/2to3/lib2to3/refactor.py", python, options)
- two_to_three_bin = Relative(ported_lib+"/2to3/2to3", python, options)
+ fast_target = Relative(ported_lib(python) +"/2to3/lib2to3/refactor.py",
+ python, options)
+ two_to_three_bin = Relative(ported_lib(python) + "/2to3/2to3", python,
+ options)
two_to_three_dir = Relative("lib/2to3_data", python, options)
env = BuildEnv({"PYTHONPATH": two_to_three_dir},
inherit_env=options.inherit_env)
@@ -1339,7 +1362,8 @@
def MeasureChameleon(python, options):
bm_path = Relative("performance/bm_chameleon.py", python, options)
- lib_path = Relative(ported_lib+"/Chameleon-2.9.2/src", python, options)
+ lib_path = Relative(ported_lib(python) + "/Chameleon-2.9.2/src",
+ python, options)
bm_env = {"PYTHONPATH": lib_path}
return MeasureGeneric(python, options, bm_path, bm_env, iteration_scaling=3)
@@ -1507,7 +1531,7 @@
def MeasureMako(python, options):
bm_path = Relative("performance/bm_mako.py", python, options)
- mako_path = Relative(ported_lib+"/mako-0.3.6", python, options)
+ mako_path = Relative(ported_lib(python) + "/mako-0.3.6", python, options)
bm_env = BuildEnv({"PYTHONPATH": mako_path}, options.inherit_env)
return MeasureGeneric(python, options, bm_path, bm_env, iteration_scaling=5)
@@ -1518,7 +1542,7 @@
def MeasureMakoV2(python, options):
bm_path = Relative("performance/bm_mako_v2.py", python, options)
- mako_path = Relative(ported_lib+"/Mako-0.7.3", python, options)
+ mako_path = Relative(ported_lib(python) + "/Mako-0.7.3", python, options)
bm_env = BuildEnv({"PYTHONPATH": mako_path}, options.inherit_env)
return MeasureGeneric(python, options, bm_path, bm_env,
iteration_scaling=10)
--
Repository URL: http://hg.python.org/benchmarks
More information about the Python-checkins
mailing list