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 interval counts frames presented,
stamped with their own present time, so it agrees 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. The headline rate is derived from that cost —
the HUD never drives the frame loop, so nothing it reports is something it
caused.
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 and its frame budget. 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.