easybench-rs icon indicating copy to clipboard operation
easybench-rs copied to clipboard

allow functions in bench_env to own the parameter

Open cod10129 opened this issue 2 years ago • 1 comments

I saw that bench_env and gen_env both give the function to be benchmarked a mutable reference, not the actual value. Is there a reason for this?

cod10129 avatar Apr 27 '23 12:04 cod10129

If we passed ownership of the environment to the closure, the environment would be dropped before the closure returns, and the time taken to run the destructor would be included in the results. For large environments, this can be significant.

asayers avatar Apr 28 '23 07:04 asayers