Skip to main content

LatencyRing

Struct LatencyRing 

Source
pub struct LatencyRing<const CAP: usize = 4096> { /* private fields */ }
Expand description

Fixed-capacity (const-generic) ring of u64 nanos — a sliding window, not an accumulator. Allocation-free on every path: stats() works from a stack-resident scratch copy sized by CAP (default 4096 → 32 KiB — document your stack when embedding with larger capacities). REQ-CLK-006.

Implementations§

Source§

impl<const CAP: usize> LatencyRing<CAP>

Source

pub const fn new() -> Self

An empty ring.

Source

pub fn record(&mut self, interval_ns: u64)

Record one interval. O(1); when the window is full the oldest sample is evicted. REQ-CLK-006.

Source

pub fn stats(&self) -> IntervalStats

Exact statistics over the current window. Zero heap allocation; scratch is a stack-resident CAP-sized copy (heapsorted in place — iterative, no recursion). REQ-CLK-006.

Source

pub const fn len(&self) -> usize

Live samples in the window (≤ CAP).

Source

pub const fn is_empty(&self) -> bool

True when nothing has been recorded.

Source

pub fn reset(&mut self)

Clear the window (reuses the allocation-free buffer).

Trait Implementations§

Source§

impl<const CAP: usize> Debug for LatencyRing<CAP>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const CAP: usize> Default for LatencyRing<CAP>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const CAP: usize> Freeze for LatencyRing<CAP>
where [u64; CAP]: Freeze,

§

impl<const CAP: usize> RefUnwindSafe for LatencyRing<CAP>
where [u64; CAP]: RefUnwindSafe,

§

impl<const CAP: usize> Send for LatencyRing<CAP>
where [u64; CAP]: Send,

§

impl<const CAP: usize> Sync for LatencyRing<CAP>
where [u64; CAP]: Sync,

§

impl<const CAP: usize> Unpin for LatencyRing<CAP>
where [u64; CAP]: Unpin,

§

impl<const CAP: usize> UnsafeUnpin for LatencyRing<CAP>
where [u64; CAP]: UnsafeUnpin,

§

impl<const CAP: usize> UnwindSafe for LatencyRing<CAP>
where [u64; CAP]: UnwindSafe,

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.