pub struct RingStats<const N: usize> { /* private fields */ }Expand description
Fixed-size ring buffer of u32 samples. push overwrites the oldest
entry once full – the only state this holds is values/len/next,
all stack-sized by the const generic N, so a profiler holding several
of these never allocates past its own construction.
Implementations§
Source§impl<const N: usize> RingStats<N>
impl<const N: usize> RingStats<N>
pub fn push(&mut self, value: u32)
Sourcepub fn stats(&self) -> Distribution
pub fn stats(&self) -> Distribution
Nearest-rank percentiles over whatever the ring currently holds.
Percentiles do not care about chronological order, so this sorts a
stack-local COPY of the valid slice (values is [u32; N], Copy
because u32 is Copy – never a heap allocation) rather than the
ring itself, which must keep its own write position intact for the
next push.
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize> Freeze for RingStats<N>
impl<const N: usize> RefUnwindSafe for RingStats<N>
impl<const N: usize> Send for RingStats<N>
impl<const N: usize> Sync for RingStats<N>
impl<const N: usize> Unpin for RingStats<N>
impl<const N: usize> UnsafeUnpin for RingStats<N>
impl<const N: usize> UnwindSafe for RingStats<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more