Function allocation_counter::avoid_counting
source · pub fn avoid_counting<F: FnOnce()>(run_while_not_counting: F)
Expand description
Opt out of counting allocations while running some code.
Useful to avoid certain parts of the code flow that should not be counted.
Arguments
run_while_not_counting
- The code to run while not counting allocations
Examples
let info = allocation_counter::measure(|| {
code_that_should_not_allocate();
allocation_counter::avoid_counting(|| {
external_code_that_should_not_be_tested();
});
code_that_should_not_allocate();
});
assert_eq!(info.count_total, 0);