Mojo struct
Bench
Defines the main Benchmark struct which executes a Benchmark and print result.
Fields
- config (
BenchConfig
): Constructs a Benchmark object based on specific configuration and mode. - mode (
Mode
): Benchmark mode object representing benchmark or test mode. - info_vec (
List[BenchmarkInfo, 0]
): A list containing the bencmark info.
Implemented traits
AnyType
,
Copyable
,
Movable
Methods
__init__
__init__(inout self: Self, config: Optional[BenchConfig] = #kgen.none, mode: Mode = 0)
Constructs a Benchmark object based on specific configuration and mode.
Args:
- config (
Optional[BenchConfig]
): Benchmark configuration object to control length and frequency of benchmarks. - mode (
Mode
): Benchmark mode object representing benchmark or test mode.
bench_with_input
bench_with_input[T: AnyType, bench_fn: fn(inout Bencher, $0) capturing -> None](inout self: Self, bench_id: BenchId, input: T, measures: List[ThroughputMeasure, 0] = List())
Benchmarks an input function with input args of type AnyType.
Parameters:
- T (
AnyType
): Benchmark function input type. - bench_fn (
fn(inout Bencher, $0) capturing -> None
): The function to be benchmarked.
Args:
- bench_id (
BenchId
): The benchmark Id object used for identification. - input (
T
): Represents the target function's input arguments. - measures (
List[ThroughputMeasure, 0]
): Optional arg used to represent a list of ThroughputMeasure's.
bench_with_input[T: AnyType, bench_fn: fn(inout Bencher, $0) capturing -> None](inout self: Self, bench_id: BenchId, input: T, *measures: ThroughputMeasure)
Benchmarks an input function with input args of type AnyType.
Parameters:
- T (
AnyType
): Benchmark function input type. - bench_fn (
fn(inout Bencher, $0) capturing -> None
): The function to be benchmarked.
Args:
- bench_id (
BenchId
): The benchmark Id object used for identification. - input (
T
): Represents the target function's input arguments. - *measures (
ThroughputMeasure
): Variadic arg used to represent a list of ThroughputMeasure's.
bench_with_input[T: AnyTrivialRegType, bench_fn: fn(inout Bencher, $0) capturing -> None](inout self: Self, bench_id: BenchId, input: T, measures: List[ThroughputMeasure, 0] = List())
Benchmarks an input function with input args of type AnyTrivialRegType.
Parameters:
- T (
AnyTrivialRegType
): Benchmark function input type. - bench_fn (
fn(inout Bencher, $0) capturing -> None
): The function to be benchmarked.
Args:
- bench_id (
BenchId
): The benchmark Id object used for identification. - input (
T
): Represents the target function's input arguments. - measures (
List[ThroughputMeasure, 0]
): Optional arg used to represent a list of ThroughputMeasure's.
bench_with_input[T: AnyTrivialRegType, bench_fn: fn(inout Bencher, $0) capturing -> None](inout self: Self, bench_id: BenchId, input: T, *measures: ThroughputMeasure)
Benchmarks an input function with input args of type AnyTrivialRegType.
Parameters:
- T (
AnyTrivialRegType
): Benchmark function input type. - bench_fn (
fn(inout Bencher, $0) capturing -> None
): The function to be benchmarked.
Args:
- bench_id (
BenchId
): The benchmark Id object used for identification. - input (
T
): Represents the target function's input arguments. - *measures (
ThroughputMeasure
): Variadic arg used to represent a list of ThroughputMeasure's.
bench_function
bench_function[bench_fn: fn(inout Bencher) capturing -> None](inout self: Self, bench_id: BenchId, measures: List[ThroughputMeasure, 0] = List())
Benchmarks or Tests an input function.
Parameters:
- bench_fn (
fn(inout Bencher) capturing -> None
): The function to be benchmarked.
Args:
- bench_id (
BenchId
): The benchmark Id object used for identification. - measures (
List[ThroughputMeasure, 0]
): Optional arg used to represent a list of ThroughputMeasure's.
bench_function[bench_fn: fn(inout Bencher) capturing -> None](inout self: Self, bench_id: BenchId, *measures: ThroughputMeasure)
Benchmarks or Tests an input function.
Parameters:
- bench_fn (
fn(inout Bencher) capturing -> None
): The function to be benchmarked.
Args:
- bench_id (
BenchId
): The benchmark Id object used for identification. - *measures (
ThroughputMeasure
): Variadic arg used to represent a list of ThroughputMeasure's.
bench_function[bench_fn: fn(inout Bencher) raises capturing -> None](inout self: Self, bench_id: BenchId, measures: List[ThroughputMeasure, 0] = List())
Benchmarks or Tests an input function.
Parameters:
- bench_fn (
fn(inout Bencher) raises capturing -> None
): The function to be benchmarked.
Args:
- bench_id (
BenchId
): The benchmark Id object used for identification. - measures (
List[ThroughputMeasure, 0]
): Optional arg used to represent a list of ThroughputMeasure's.
bench_function[bench_fn: fn(inout Bencher) raises capturing -> None](inout self: Self, bench_id: BenchId, *measures: ThroughputMeasure)
Benchmarks or Tests an input function.
Parameters:
- bench_fn (
fn(inout Bencher) raises capturing -> None
): The function to be benchmarked.
Args:
- bench_id (
BenchId
): The benchmark Id object used for identification. - *measures (
ThroughputMeasure
): Variadic arg used to represent a list of ThroughputMeasure's.
dump_report
dump_report(self: Self)
Prints out the report from a Benchmark execution.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!