Skip to main content

Module performance

Module performance 

Source
Expand description

PerformanceView — Mean CPU usage label + frame-time sparkline.

Apps wire a SharedFrameHistory from their main loop into the widget’s constructor, then push each completed frame’s wall time via FrameHistory::push. The widget renders the rolling mean as “Mean CPU usage: X.XX ms / frame” plus a sparkline graph below — same presentation used in the agg-gui demo’s Backend panel and the egui reference’s frame_history widget.

This is intentionally a minimal, self-contained widget (one Label child for glyph caching, one direct paint pass for the sparkline) so it drops into any container — a side panel, a popup window, a collapsing header — without extra plumbing.

Structs§

FrameHistory
Rolling buffer of recent frame times in milliseconds. Apps push from the main loop; widgets read for display. Sized for ~1 second at 60 fps (matches the egui reference and the prior demo_ui copy).
PerformanceView
“Mean CPU usage” label stacked above a frame-time sparkline.
RunModeDesc
Dynamic label that mirrors the current run mode. Reactive — “Only running UI code when there are animations or input.” Continuous — “Running continuously as fast as possible. FPS: X.X”
RunModeRow
Reactive / Continuous segmented selector composed from two real Button children that share an Rc<Cell<RunMode>>. Used inside PerformanceView when super::PerformanceView::with_run_mode_selector is wired; safe to use standalone for hosts that want the picker without the perf graph.

Enums§

RunMode
How the host’s event loop drives repaints.

Functions§

paint_sparkline
Paint a frame-time sparkline at (x, y, w, h) in the active DrawCtx’s coordinate space. Reads from history for samples and draws an orange 16.7 ms (60 fps) reference line. Exposed in case a caller wants the graph without the surrounding label / padding.
shared_frame_history
Convenience: heap-allocate a fresh shared history. Equivalent to Rc::new(RefCell::new(FrameHistory::new())).
shared_run_mode
Convenience: wrap a RunMode in the Rc<Cell<…>> plumbing that super::PerformanceView::with_run_mode_selector expects.

Type Aliases§

SharedFrameHistory
Shared handle to a FrameHistory — passed to the widget at construction and to the platform shell so it can push samples.