Function bench_diff

Source
pub fn bench_diff(
    unit: LatencyUnit,
    f1: impl FnMut(),
    f2: impl FnMut(),
    exec_count: usize,
) -> DiffOut
Expand description

Compares latencies for two closures f1 and f2.

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. This function calls bench_diff_x with no-op closures for the arguments that support the output of benchmark status.

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.