Skip to main content

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, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable

comptime members

__copyinit__is_trivial

comptime __copyinit__is_trivial = True

__del__is_trivial

comptime __del__is_trivial = True

__moveinit__is_trivial

comptime __moveinit__is_trivial = True

Methods

mean

mean(self, unit: String = Unit.s) -> Float64

Returns the average duration of the batch.

Args:

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

Returns:

Float64: The average duration of the batch.

Was this page helpful?