pub struct BinStatsWindow { /* private fields */ }Expand description
A snapshot of bin stats taken at a fixed point in time.
Create a baseline with BinStatsWindow::capture, then call
BinStatsWindow::delta later to compute per-class deltas over the window.
This is the recommended pattern for profiling a code region:
let baseline = BinStatsWindow::capture();
// ... code under profiling ...
let delta = baseline.delta();Implementations§
Source§impl BinStatsWindow
impl BinStatsWindow
Sourcepub fn capture() -> Self
pub fn capture() -> Self
Captures the current per-class bin stats as a baseline.
Flushes the calling thread’s TLS batch first so the snapshot reflects all preceding allocations on this thread.
Sourcepub fn delta(&self) -> [BinSnapshot; 52]
pub fn delta(&self) -> [BinSnapshot; 52]
Computes per-class deltas since the baseline was captured.
Each returned snapshot has its counters set to the difference since the baseline. Counters that decreased (or were reset) saturate to zero.
Sourcepub fn total_alloc_count_delta(&self) -> u64
pub fn total_alloc_count_delta(&self) -> u64
Total allocations during the window across all size classes.
Sourcepub fn total_live_bytes_delta(&self) -> u64
pub fn total_live_bytes_delta(&self) -> u64
Total live bytes at the end of the window minus the start.
Sourcepub fn total_requested_bytes_delta(&self) -> u64
pub fn total_requested_bytes_delta(&self) -> u64
Total user-requested bytes during the window across all size classes.
Requires record_alloc_with_size to have been used at call sites.
Sourcepub fn window_internal_fragmentation(&self) -> f64
pub fn window_internal_fragmentation(&self) -> f64
Internal fragmentation ratio over the window:
(total_alloc_bytes_delta - total_requested_bytes_delta) / total_alloc_bytes_delta.
Returns 0.0 when total_alloc_bytes_delta == 0 or requested is zero.