Skip to main content
Log in

Mojo struct

Batch

@register_passable(trivial) struct Batch

A batch of benchmarks, the benchmark.run() function works out how many iterations to run in each batch based the how long the previous iterations took.

Fields

  • duration (Int): Total duration of batch stored as nanoseconds.
  • iterations (Int): Total iterations in the batch.

Implemented traits

AnyType, CollectionElement, Copyable, ExplicitlyCopyable, Movable, UnknownDestructibility

Methods

__init__

__init__(*, other: Self) -> Self

Explicitly construct a deep copy of the provided value.

Args:

  • other (Self): The value to copy.

mean

mean(self, unit: String = String("s")) -> SIMD[float64, 1]

Returns the average duration of the batch.

Args:

  • unit (String): The time unit to display for example: ns, ms, s (default s).

Returns:

The average duration of the batch.