Available on crate feature
alloc-tracking only.Expand description
Allocation tracking. Available with the alloc-tracking feature.
Wraps dhat to capture total bytes, total allocation count, and
peak resident bytes during a benchmark. Reports a CheckResult
with regression-style verdict.
§Cost
Enabling alloc-tracking installs dhat::Alloc as the global
allocator. This is heavier than the default allocator and
materially changes timing characteristics. Do not combine
allocation thresholds with timing thresholds in the same
invocation. Run timing benchmarks with the feature off and
allocation benchmarks with it on.
§Setup
Use the install_global_allocator!
macro at module scope in your binary or test target:
ⓘ
dev_bench::install_global_allocator!();Then start a profiler before the benchmark and snapshot stats after:
ⓘ
let _profiler = dhat::Profiler::new_heap();
// ... run benchmarked code ...
let stats = dev_bench::alloc::AllocationStats::snapshot();The macro expands to:
ⓘ
#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc;Structs§
- Allocation
Stats - Snapshot of allocation activity, captured from
dhat::HeapStats.