pub struct StalenessWindow { /* private fields */ }Expand description
A staleness-weighted window of recent scalar observations (e.g. per-step loss
under the current config). push advances the clock; weighted_mean reports
the freshness-weighted average; observations past k2 are evicted.
Implementations§
Source§impl StalenessWindow
impl StalenessWindow
Sourcepub fn new(schedule: StalenessSchedule, cap: usize) -> Self
pub fn new(schedule: StalenessSchedule, cap: usize) -> Self
New window with the given schedule and a hard capacity cap.
Sourcepub fn push(&mut self, value: f32)
pub fn push(&mut self, value: f32)
Record an observation under the current config; advances the clock and
evicts samples that are too stale (age > k2) or over capacity.
Sourcepub fn clear_samples(&mut self)
pub fn clear_samples(&mut self)
Reset the recorded observations but keep the clock running — used after a config switch so the new config is scored on its own fresh samples.
Sourcepub fn weighted_mean(&self) -> Option<f32>
pub fn weighted_mean(&self) -> Option<f32>
Staleness-weighted mean of the window, or None if empty / all-stale.
Trait Implementations§
Source§impl Clone for StalenessWindow
impl Clone for StalenessWindow
Source§fn clone(&self) -> StalenessWindow
fn clone(&self) -> StalenessWindow
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StalenessWindow
impl RefUnwindSafe for StalenessWindow
impl Send for StalenessWindow
impl Sync for StalenessWindow
impl Unpin for StalenessWindow
impl UnsafeUnpin for StalenessWindow
impl UnwindSafe for StalenessWindow
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