Expand description
Per-thread allocation counting, to prove hot paths never touch the heap.
Install CountingAllocator as the global allocator of a binary or test crate:
ⓘ
#[global_allocator]
static ALLOCATOR: densa_alloc::CountingAllocator = densa_alloc::CountingAllocator::system();then wrap the code under test in measure. Counters are per thread, so other threads
(test harness, workers) never pollute a measurement. Without the allocator installed all
counters stay at zero; always check is_active first so a zero-allocation assertion
cannot pass vacuously.
Structs§
- Alloc
Stats - Heap operations observed on one thread.
- Counting
Allocator - A
GlobalAllocwrapper that counts every heap operation per thread.
Functions§
- is_
active trueifCountingAllocatoris the active global allocator.- measure
- Runs
fand returns its result with the heap operations it performed on this thread. - thread_
stats - Snapshot of the calling thread’s cumulative counters.