Skip to main content

Mojo struct

BenchConfig

Defines a benchmark configuration struct to control execution times and frequency.

Aliases

  • VERBOSE_TIMING_LABELS = "min (ms)", "mean (ms)", "max (ms)", "duration (ms)": Labels to print verbose timing results.

Fields

  • out_file (Optional[Path]): Output file to write results to.
  • min_runtime_secs (SIMD[float64, 1]): Upper bound on benchmarking time in secs.
  • max_runtime_secs (SIMD[float64, 1]): Lower bound on benchmarking time in secs.
  • max_batch_size (Int): The maximum number of iterations to perform per time measurement.
  • max_iters (Int): Max number of iterations to run.
  • warmup_iters (Int): Number of warmup iterations to run before starting benchmarking.
  • num_repetitions (Int): Number of times the benchmark has to be repeated.
  • flush_denormals (Bool): Whether or not the denormal values are flushed.
  • show_progress (Bool): Whether or not to show the progress of each benchmark.
  • tabular_view (Bool): Whether to print results in csv readable/tabular format.
  • verbose_timing (Bool): Whether to print verbose timing results.

Implemented traits

AnyType, CollectionElement, Copyable, Movable

Methods

__init__

__init__(inout self: Self, out_file: Optional[Path] = #kgen.none, min_runtime_secs: SIMD[float64, 1] = #kgen.float_literal<1|10>, max_runtime_secs: SIMD[float64, 1] = 1, warmup_iters: Int = 2, max_batch_size: Int = 0, max_iters: Int = 1000000000, num_repetitions: Int = 1, flush_denormals: Bool = 1)

Constructs and initializes Benchmark config object with default and inputed values.

Args:

  • out_file (Optional[Path]): Output file to write results to.
  • min_runtime_secs (SIMD[float64, 1]): Upper bound on benchmarking time in secs (default 0.1).
  • max_runtime_secs (SIMD[float64, 1]): Lower bound on benchmarking time in secs (default 1).
  • warmup_iters (Int): Number of warmup iterations to run before starting benchmarking (default 2).
  • max_batch_size (Int): The maximum number of iterations to perform per time measurement.
  • max_iters (Int): Max number of iterations to run (default 1_000_000_000).
  • num_repetitions (Int): Number of times the benchmark has to be repeated.
  • flush_denormals (Bool): Whether or not the denormal values are flushed.

__init__(inout self: Self, *, other: Self)

Explicitly construct a deep copy of the provided value.

Args:

  • other (Self): The value to copy.