legate.util.benchmark.benchmark_log#
- legate.util.benchmark.benchmark_log(
- name: str,
- columns: list[str],
- *,
- out: TextIO | None = None,
- metadata: dict[str, Any] | None = None,
- start_runtime: bool = True,
Create a context manager for logging tables of data generated for benchmarking legate code.
The context manager will write a table of benchmarking data to a specified output textstream, including with the table a header comment with reproducibility data about how the benchmark was run.
- Parameters:
name (str) – The name for the benchmark.
columns (list[str]) – A list of headers for the columns of data in the table.
out (TextIO | None = None) – Optional io stream for benchmark data: e.g.
out=sys.stdoutto write benchmark data to the screen. Ifoutis not specified, the destination of benchmark data depends on the LEGATE_BENCHMARK_OUT environment variable. By default, this variable isstdout, in which case benchmark data will be written tosys.stdout(see also LEGATE_LIMIT_STDOUT). If instead this is a directory, e.g.LEGATE_BENCHMARK_OUT=${PWD}, then a unique basename will be generated for a set of output csv files (one per rank) in that directory. (The legate command line option--benchmark-to-fileis equivalent to settingLEGATE_BENCHMARK_OUTto have the same value as the directory as--logdir.) For example, ifnameismybench, then rankPwill write its benchmark data tomybench_[unique hex string].P.csv.metadata (dict[str, Any] | None = None) – Optional dictionary of metadata that will be included in the header of the table. If
None,legate.util.info.info()will be used to generate the metadata.start_runtime (bool = True) – By default,
benchmark_log()uses the legate runtime to populate metadata and, in multi-rank programs, to determine a globally unique id for each benchmark. Ifstart_runtime=Falseis specified, the legate runtime will not be started if it is not already running: each rank in a multiprocess program will generate a different id, and metadata about the runtime and machine configuration of legate will be missing.
- Returns:
A context manager whose primary method is
log(), which adds a row of benchmark data to the table.- Return type: