[][src]Function easybench::bench_gen_env

pub fn bench_gen_env<G, F, I, O>(gen_env: G, f: F) -> Stats where
    G: FnMut() -> I,
    F: FnMut(&mut I) -> O, 

Run a benchmark with a generated environment.

The function gen_env creates the "benchmark environment" for the computation. Each iteration receives a freshly-created environment. The time taken to create the environment is not included in the results.

Nb: it's very possible that we will end up generating many (>10,000) copies of env at the same time. Probably best to keep it small.

See bench and the module docs for more.

Overhead

Every iteration, bench_gen_env performs a lookup into a big vector in order to get the environment for that iteration. If your benchmark is memory-intensive then this could, in the worst case, amount to a systematic cache-miss (ie. this vector would have to be fetched from DRAM at the start of every iteration). In this case the results could be affected by a hundred nanoseconds. This is a worst-case scenario however, and I haven't actually been able to trigger it in practice... but it's good to be aware of the possibility.