pub struct RateModel { /* private fields */ }Expand description
One lane’s throughput estimate in samples per second. See the module doc.
Implementations§
Source§impl RateModel
impl RateModel
Sourcepub const fn new(initial_guess: f64) -> Self
pub const fn new(initial_guess: f64) -> Self
An uncalibrated model starting from initial_guess samples per second. The
guess only matters for reporting (Self::rate); an uncalibrated lane’s first
chunk is ChunkPolicy::first_chunk_samples long regardless.
Sourcepub fn calibrated(rate: f64) -> Self
pub fn calibrated(rate: f64) -> Self
A model already calibrated at rate (carried over from an earlier epoch of the
same lane, e.g. the previous tilt-video frame), so no calibration chunk is spent.
A non-finite or non-positive rate yields an uncalibrated model instead.
Sourcepub const fn with_smoothing(self, weight_of_new: f64) -> Self
pub const fn with_smoothing(self, weight_of_new: f64) -> Self
Replaces the moving-average weight of a new measurement; clamped to
[0.01, 1.0] (1.0 means “always trust the latest chunk”).
Sourcepub const fn is_calibrated(&self) -> bool
pub const fn is_calibrated(&self) -> bool
Whether at least one real measurement has replaced the guess.
Sourcepub const fn estimate(&self) -> Option<f64>
pub const fn estimate(&self) -> Option<f64>
The calibrated estimate only (None while uncalibrated) – what a caller
carries into the next epoch with Self::calibrated.
Sourcepub const fn observations(&self) -> u32
pub const fn observations(&self) -> u32
Measurements folded in so far.
Sourcepub fn observe(
&mut self,
done: u32,
elapsed: Duration,
reported: Option<f64>,
) -> Option<f64>
pub fn observe( &mut self, done: u32, elapsed: Duration, reported: Option<f64>, ) -> Option<f64>
Folds in one finished chunk: done samples in elapsed wall time, with the
lane’s own reported marginal rate preferred when it is valid. Returns the
measurement used, or None (model unchanged) when there was nothing to measure.
Sourcepub fn chunk_samples(&self, policy: &ChunkPolicy) -> u32
pub fn chunk_samples(&self, policy: &ChunkPolicy) -> u32
The size of this lane’s next chunk under policy: the calibration chunk while
uncalibrated, otherwise ChunkPolicy::samples_for_rate of the estimate.