Skip to content
Snippets Groups Projects
Commit fb0b93ea authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

runner: move the `_time_command` around

parent 5ce76f1d
No related branches found
No related tags found
1 merge request!13bunch of new things.
......@@ -144,6 +144,38 @@
self.cwd = get_var(key)
def _time_command(bin_env_path, data_env_path, cmd):
bin_env_path = os.path.abspath(bin_env_path)
data_env_path = os.path.abspath(data_env_path)
shell_path = poulpe.bin_env_script(bin_env_path)
with tempfile.NamedTemporaryFile('w') as tmp_result:
time_cmd = [
shell_path,
"hyperfine",
"--export-json",
tmp_result.name,
"--",
cmd.command,
]
if cmd.accept_failure:
time_cmd.insert(-2, "--ignore-failure")
cwd = data_env_path
if cmd.cwd is not None:
cwd = os.path.join(cwd, cmd.cwd)
subprocess.check_call(
time_cmd,
cwd=cwd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
with open(tmp_result.name) as f:
return json.load(f)
def run_one(bin_env_path, data_env_path, benchmark_path, result):
result_data = {}
result_data['run'] = {}
......@@ -177,35 +209,3 @@
poulpe.write_data(result, result_data)
return 0
def _time_command(bin_env_path, data_env_path, cmd):
bin_env_path = os.path.abspath(bin_env_path)
data_env_path = os.path.abspath(data_env_path)
shell_path = poulpe.bin_env_script(bin_env_path)
with tempfile.NamedTemporaryFile('w') as tmp_result:
time_cmd = [
shell_path,
"hyperfine",
"--export-json",
tmp_result.name,
"--",
cmd.command,
]
if cmd.accept_failure:
time_cmd.insert(-2, "--ignore-failure")
cwd = data_env_path
if cmd.cwd is not None:
cwd = os.path.join(cwd, cmd.cwd)
subprocess.check_call(
time_cmd,
cwd=cwd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
with open(tmp_result.name) as f:
return json.load(f)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment