Skip to main content

EmaF64

Struct EmaF64 

Source
pub struct EmaF64 { /* private fields */ }
Expand description

Exponential moving average over f64 samples, with an alpha-per-update-call smoothing factor (rather than a fixed-at-construction one) so a single small primitive can back both this module’s per-stage profiler (alpha 0.08, the source app’s own constant) and uzor-desktop::Manager’s own whole-frame fps_ema (alpha 0.1) without needing two copies of the formula.

Implementations§

Source§

impl EmaF64

Source

pub fn new() -> Self

A fresh, uninitialized tracker — its very first EmaF64::update call wins outright (no smoothing against 0.0).

Source

pub fn seeded(value: f64) -> Self

A tracker pre-seeded with value, marked initialized — the first real EmaF64::update call blends against value instead of replacing it outright. Useful when a caller has a sensible starting guess (e.g. an assumed 60.0 fps before the first frame has actually been timed) rather than wanting the very first sample to jump straight to its own raw value.

Source

pub fn update(&mut self, sample: f64, alpha: f64) -> f64

Fold sample into the running average at smoothing factor alpha (0.0..=1.0; higher = more responsive to new samples, lower = smoother/slower) and return the new value. The very first call on an uninitialized (Self::new/Self::default) tracker always wins outright — matches both source call sites’ own if initialized { blend } else { sample } cold-start rule, avoiding a synthetic warm-up period biased toward whatever value the struct happened to start at.

Source

pub fn value(&self) -> f64

Current smoothed value (0.0 if never updated and not seeded).

Source

pub fn is_initialized(&self) -> bool

Whether at least one EmaF64::update has run, or the tracker was constructed via EmaF64::seeded.

Trait Implementations§

Source§

impl Clone for EmaF64

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for EmaF64

Source§

impl Debug for EmaF64

Source§

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

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

impl Default for EmaF64

Source§

fn default() -> Self

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

impl PartialEq for EmaF64

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EmaF64

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.