Skip to main content

Crate densa_alloc

Crate densa_alloc 

Source
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§

AllocStats
Heap operations observed on one thread.
CountingAllocator
A GlobalAlloc wrapper that counts every heap operation per thread.

Functions§

is_active
true if CountingAllocator is the active global allocator.
measure
Runs f and returns its result with the heap operations it performed on this thread.
thread_stats
Snapshot of the calling thread’s cumulative counters.