Skip to main content

struct

Bencher

Defines a Bencher struct which facilitates the timing of a target function.

Fields

  • num_iters (Int): Number of iterations to run the target function.
  • elapsed (Int): The total time elpased when running the target function.

Implemented traits

AnyType, Copyable, Movable

Methods

__init__

__init__(inout self: Self, num_iters: Int)

Constructs a Bencher object to run and time a function.

Args:

  • num_iters (Int): Number of times to run the target function.

iter

iter[iter_fn: fn() capturing -> None](inout self: Self)

Returns the total elapsed time by running a target function a particular number of times.

Parameters:

  • iter_fn (fn() capturing -> None): The target function to benchmark.

iter[iter_fn: fn() raises capturing -> None](inout self: Self)

Returns the total elapsed time by running a target function a particular number of times.

Parameters:

  • iter_fn (fn() raises capturing -> None): The target function to benchmark.

iter_custom

iter_custom[iter_fn: fn(Int) capturing -> Int](inout self: Self)

Times a target function with custom number of iterations.

Parameters:

  • iter_fn (fn(Int) capturing -> Int): The target function to benchmark.

iter_custom[iter_fn: fn(Int) raises capturing -> Int](inout self: Self)

Times a target function with custom number of iterations.

Parameters:

  • iter_fn (fn(Int) raises capturing -> Int): The target function to benchmark.