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>
impl<const CAP: usize> LatencyRing<CAP>
Sourcepub fn record(&mut self, interval_ns: u64)
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.
Sourcepub fn stats(&self) -> IntervalStats
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.
Trait Implementations§
Source§impl<const CAP: usize> Debug for LatencyRing<CAP>
impl<const CAP: usize> Debug for LatencyRing<CAP>
Auto Trait Implementations§
impl<const CAP: usize> Freeze for LatencyRing<CAP>
impl<const CAP: usize> RefUnwindSafe for LatencyRing<CAP>
impl<const CAP: usize> Send for LatencyRing<CAP>
impl<const CAP: usize> Sync for LatencyRing<CAP>
impl<const CAP: usize> Unpin for LatencyRing<CAP>
impl<const CAP: usize> UnsafeUnpin for LatencyRing<CAP>
impl<const CAP: usize> UnwindSafe for LatencyRing<CAP>
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