Expand description
A realtime performance HUD for GPUI applications: frames per second, a rolling frame time chart, and this process’ GPU, CPU and memory usage.
Frame data comes from GPUI’s own frame trace
(gpui::FrameTimingCollector). The rate and the interval count frames
presented, stamped with their own present time, so they agree with the
platform’s overlay (Metal’s HUD counts the same drawables); the frame cost
is what the framework actually spent in Window::draw, rather than an
approximation measured from the outside.
Render it wherever it should appear, guarded by your own flag:
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
div()
.relative()
.size_full()
.child("your app")
.when(self.show_fps, |this| this.child(fps_monitor(window, cx)))
}The returned overlay can change its corner, frame budget, and whether it
continuously drives the window’s animation loop. A custom palette or an
embedded rather than overlaid HUD is built by composing FpsMonitor and
FpsOverlay directly.
This crate depends only on gpui, so it can be used from any GPUI
application.
Structs§
- FpsMonitor
- FpsOverlay
- Pins an
FpsMonitorto an edge or corner of its parent, the way a game overlays its frame counter.
Functions§
- fps_
monitor - The performance HUD, pinned to the top right of its parent.