pub fn bench_diff_x(
unit: LatencyUnit,
f1: impl FnMut(),
f2: impl FnMut(),
exec_count: usize,
warmup_status: impl FnMut(usize, u64, u64),
pre_exec: impl FnOnce(),
exec_status: impl FnMut(usize),
) -> DiffOutExpand description
Compares latencies for two closures f1 and f2 and optionally outputs information about the benchmark
and its execution status.
This function repeatedly executes duos of pairs (f1, f2), (f2, f1) and collects the resulting
latency data in a DiffOut object.
Prior to data collection, the benchmark is “warmed-up” by executing the duos of pairs for
get_warmup_millis milliseconds.
Arguments:
unit- the unit used for data collection.f1- first target for comparison.f2- second target for comparison.exec_count- number of executions (sample size) for each function.warmup_status- is invoked every so often during warm-up and can be used to output the warm-up status, e.g., how much warm-up time has elapsed and the target warm-up time. The first argument is the warm-up execution iteration, the second is the elapsed warm-up time, and the third is the target warm-up time. (See the source code ofbench_diff_with_statusfor an example.)pre_exec- is invoked once at the beginning of data collection, after warm-up. It can be used, for example, to output a preamble to the execution status (seeexec_statusbelow).exec_status- is invoked after the execution of each duo and can be used to output on the execution status, e.g., how many observations have been collected for the pair of functions versusexec_count. Its argument is the current number of executions performed. (See the source code ofbench_diff_with_statusfor an example.)