pub struct EwmaTracker { /* private fields */ }Expand description
Pure-math EWMA with promote/demote thresholds. Stateless — caller supplies the prior and the observation.
Implementations§
Source§impl EwmaTracker
impl EwmaTracker
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Recommended defaults: alpha=0.1 (~72h half-life at typical rates), promote at 0.4 / 10 samples, demote at 0.1 / 50 samples.
Sourcepub fn update(&self, prev: f32, blocked: bool) -> f32
pub fn update(&self, prev: f32, blocked: bool) -> f32
Update the EWMA given whether the current observation was a block.
§Panics (debug only)
Panics in debug builds if self.alpha is outside (0.0, 1.0). The
constructor hardcodes 0.1; this assert guards any future with_alpha
builder from silently breaking the weighted-average math.
Sourcepub fn should_promote(&self, ewma: f32, sample_count: u64) -> bool
pub fn should_promote(&self, ewma: f32, sample_count: u64) -> bool
Return true if the EWMA and sample count warrant promoting to a
higher tier.
Sourcepub fn should_demote(&self, ewma: f32, sample_count: u64) -> bool
pub fn should_demote(&self, ewma: f32, sample_count: u64) -> bool
Return true if the EWMA and sample count warrant demoting to a
lower tier.
Trait Implementations§
Source§impl Clone for EwmaTracker
impl Clone for EwmaTracker
Source§fn clone(&self) -> EwmaTracker
fn clone(&self) -> EwmaTracker
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 moreimpl Copy for EwmaTracker
Source§impl Debug for EwmaTracker
impl Debug for EwmaTracker
Auto Trait Implementations§
impl Freeze for EwmaTracker
impl RefUnwindSafe for EwmaTracker
impl Send for EwmaTracker
impl Sync for EwmaTracker
impl Unpin for EwmaTracker
impl UnsafeUnpin for EwmaTracker
impl UnwindSafe for EwmaTracker
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