# HG changeset patch # User Pierre-Yves David <pierre-yves.david@octobus.net> # Date 1665452204 -7200 # Tue Oct 11 03:36:44 2022 +0200 # Node ID a1f47992b582d2332b98f9310e0ecf0740e5825e # Parent e93c95be7964186f23a043861150ff78e16e263d simple-command: allow for a preparation step before runs. This will help use to benchmark more complex operation. diff --git a/docs/benchmarks.rst b/docs/benchmarks.rst --- a/docs/benchmarks.rst +++ b/docs/benchmarks.rst @@ -84,6 +84,11 @@ This can be changed by variants (see next section). +prepare-run +~~~~~~~~~~~ + +A command (or series of command) to run before each command run. + variants -------- diff --git a/python-libs/poulpe/benchmarks.py b/python-libs/poulpe/benchmarks.py --- a/python-libs/poulpe/benchmarks.py +++ b/python-libs/poulpe/benchmarks.py @@ -202,7 +202,10 @@ cmd = SimpleCommand(self) cmd.apply_data_env(data_env) - r = self._time_command(bin_env_path, data_env_path, cmd) + + prepare = self.get_var('simple-command.prepare-run') + + r = self._time_command(bin_env_path, data_env_path, cmd, prepare) res = {} # we should store more res['time'] = {} @@ -213,7 +216,7 @@ res['time']['max'] = r['results'][0]['max'] return res - def _time_command(self, bin_env_path, data_env_path, cmd): + def _time_command(self, bin_env_path, data_env_path, cmd, prepare=None): 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) @@ -230,11 +233,16 @@ "--export-json", tmp_result.name, '--show-output', - "--", - cmd.command, ] if cmd.accept_failure: - time_cmd.insert(-2, "--ignore-failure") + time_cmd.append("--ignore-failure") + + if prepare is not None: + time_cmd.append('--prepare') + time_cmd.append(prepare) + + time_cmd.append("--") + time_cmd.append(cmd.command) cwd = data_env_path if cmd.cwd is not None: