Skip to main content

BinStatsWindow

Struct BinStatsWindow 

Source
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

Source

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.

Source

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.

Source

pub fn total_alloc_count_delta(&self) -> u64

Total allocations during the window across all size classes.

Source

pub fn total_live_bytes_delta(&self) -> u64

Total live bytes at the end of the window minus the start.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.