k4bench.runner.process¶
k4bench.runner.process ¶
Run one command under /usr/bin/time -v and harvest what it measured.
This is the tool-independent half of a benchmark run: building the timed
shell command, streaming the process output into its log, stopping the whole
process group on Ctrl-C, and parsing the time -v report. It knows nothing
about which program it times; :mod:k4bench.runner.ddsim and
:mod:k4bench.runner.k4run supply the command line, and
:mod:k4bench.runner.result turns the outcome into a
:class:~k4bench.results.model.RunResult.
TimedProcess
dataclass
¶
Outcome of one timed process: its exit code and the parsed
time -v metrics (see :func:~k4bench.runner.parser.parse_time_output
for the keys; each is None when the report lacked it).
timed_shell_command ¶
timed_shell_command(argv: list[str], setup_script: Path | None = None, after_setup: str = '') -> str
Return the bash command that runs argv under GNU time -v.
setup_script, when given, is sourced first, and the bash after_setup runs next, in the environment the script left. Every argument is shell-quoted, and one argument goes on each line so the command reads cleanly when it is echoed into a log.
Source code in k4bench/runner/process.py
run_timed ¶
run_timed(command: str, *, env: dict[str, str], log_path: Path, verbose: bool = False, cwd: Path | None = None) -> TimedProcess
Run command (from :func:timed_shell_command) in bash and wait for it.
All output goes to log_path, and to stdout as well when verbose. The
process runs in cwd (default: the current directory) and in its own
session, so a Ctrl-C stops it and every child it started before the
KeyboardInterrupt is re-raised.