Expand description
Generic named-stage frame profiler + the shared EMA helper.
Moved from the old framework module::frame_profiler. There is no JSON
sink (design L-U7); callers read FrameProfiler::stage_ms /
FrameProfiler::stages.
Stage names are caller-supplied &'static str keys, not a fixed enum.
The aggregator owns no clock and no serializer: feed milliseconds in,
read the smoothed map back out.
This module owns NO clock. It lives in the platform-agnostic core
(std::time::Instant panics at runtime on wasm32-unknown-unknown,
and this crate compiles for every window backend), so the aggregator
only ever accepts caller-measured durations via
FrameProfiler::record_ms — pure math + naming. The measuring edge
stays wherever a real monotonic clock exists (e.g.
uzor-desktop::Manager brackets with Instant and feeds the result
in; a web backend would feed performance.now() deltas).
EmaF64 deduplicates a smoothing formula that used to be
hand-rolled independently in two places: the source app’s own
FrameProfile::ema (previous * 0.92 + sample * 0.08) and
Manager’s own whole-frame fps_ema (previous * 0.9 + sample * 0.1). Manager::fps_ema’s public behavior (the f32 field, its
exact smoothing formula/seed) is unchanged — it now computes that
same formula through an EmaF64 tracker instead of the formula
written out inline a second time.
Structs§
- EmaF64
- Exponential moving average over
f64samples, 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 (alpha0.08, the source app’s own constant) anduzor-desktop::Manager’s own whole-framefps_ema(alpha0.1) without needing two copies of the formula. - Frame
Profiler - Named-stage, per-frame profiler with independent EMA smoothing per
stage — the generic mechanism behind the source app’s own
FrameProfile. Stage names are caller-supplied&'static strkeys (e.g."grid","scene_build","overlay"), not a fixed enum, so any app’s own frame-phase vocabulary ports over unchanged.