bevy_perf_hud

A configurable performance heads-up display (HUD) plugin for Bevy applications. Visualize frame pacing, entity counts, and resource usage in real time, with extensibility for your own metrics.
Table of Contents
- Features
- Installation
- Quick Start
- Advanced Configuration
- Built-in Metrics
- Custom Metrics
- Examples
- Performance Impact
- Troubleshooting
- Getting Help
- Supported Versions
- License
- Acknowledgements
Features
- Flexible HUD layout with multi-curve graphs and resource bars.
- Built-in providers for FPS, frame time, entity count, and system/process CPU & memory usage.
- Fine-grained control over smoothing, quantization, autoscaling, and appearance.
- Extensible
PerfMetricProvidertrait for custom metrics that appear alongside built-ins.
Installation
Minimum Supported Rust Version (MSRV): 1.76.0
Add the crate to your Cargo.toml:
[]
= { = "0.16", = false, = [
"bevy_winit",
"bevy_ui",
"bevy_render",
"bevy_diagnostic",
"sysinfo_plugin",
] }
= "0.1"
Feature Flags
| Feature | Description | Default |
|---|---|---|
default |
Enables all standard functionality | ✓ |
Requirements
- Bevy Features: The HUD requires
bevy_ui,bevy_diagnostic, andbevy_renderfeatures - System Metrics: Add
sysinfo_pluginfeature for CPU/memory monitoring - Platform Support: Windows, macOS, Linux (system metrics may have limited functionality on some platforms)
Tip: If you use
DefaultPlugins, the required features are already enabled. Withoutsysinfo_plugin, system/process CPU & memory providers will be silently skipped.
Quick Start
use *;
use BevyPerfHudPlugin;
By default the HUD appears near the top-right corner. To reposition or customize the layout, insert a PerfHudSettings
resource before adding the plugin:
use *;
use ;
Advanced Configuration
PerfHudSettings exposes additional knobs for tailoring the HUD:
graph: adjust canvas size, curve smoothing, quantization, and decide which metrics appear in the time-series chart.bars: control whether resource bars render, set per-metric min/max bounds, and decide when to show numeric values.enabled/origin: toggle the HUD globally and anchor it anywhere on screen.
Example: expand the graph, smooth the FPS curve, and shrink the system CPU bar range.
use *;
use ;
Built-in Metrics
| Metric ID | Description |
|---|---|
fps |
Frames per second (floored to an integer). |
frame_time_ms |
Smoothed frame time in milliseconds. |
entity_count |
Active entity count in the World. |
system/cpu_usage |
Overall system CPU usage percentage. |
system/mem_usage |
Overall system memory usage percentage. |
process/cpu_usage |
CPU usage of the running process. |
process/mem_usage |
Memory footprint of the running process (MiB). |
Custom Metrics
Implement the PerfMetricProvider trait and register it with the PerfHudAppExt helper:
Basic Example
use *;
use ;
;
Advanced Example
Here's a more realistic example that tracks multiple game metrics:
use *;
use ;
use VecDeque;
// Track active player connections
;
;
// System to update our custom metrics data
Custom Metric Guidelines
- Unique IDs: Use descriptive, hierarchical names like
"game/players"or"net/latency_ms" - Performance: Keep
sample()implementations fast - they're called every frame - Optional Values: Return
Nonewhen data isn't available rather than placeholder values - Units: Include units in the metric ID for clarity (
_ms,_mb,_percent)
Examples
The repository ships with two runnable examples:
examples/simple.rs: 3D scene with keyboard shortcuts (Space spawns cubes, F1 toggles HUD modes).examples/custom_metric.rs: Demonstrates registering an additional metric provider.
Run them with:
Performance Impact
The performance HUD is designed to have minimal impact on your application:
- CPU Usage: ~0.1-0.5% overhead on typical applications
- Memory Usage: ~2-4MB for storing historical data and UI components
- Render Cost: UI rendering typically adds <0.1ms to frame time
Optimization Tips:
- Reduce
history_samplesin graph settings for lower memory usage - Disable unused metrics by removing them from curves/bars configuration
- Use larger
update_intervalfor custom metrics that are expensive to sample - Consider disabling the HUD in release builds using feature flags
Troubleshooting
Common Issues
HUD not appearing:
- Ensure
bevy_uifeature is enabled in your Bevy dependency - Check that you're using
DefaultPluginsor have added the required UI plugins manually - Verify the HUD isn't positioned outside your window bounds
Missing system metrics (CPU/Memory):
- Add the
sysinfo_pluginfeature to your Bevy dependency - Without this feature, system/process metrics will be silently skipped
Poor performance with many entities:
- The
entity_countmetric can impact performance with 100k+ entities - Consider removing it from the HUD configuration for very large worlds
Custom metrics not updating:
- Ensure your
PerfMetricProvider::sample()method returnsSome(value) - Check that the provider is properly registered with
add_perf_metric_provider() - Verify the metric ID is unique and doesn't conflict with built-in metrics
Performance Debugging
If the HUD itself is causing performance issues:
// Temporarily disable to isolate performance problems
.insert_resource
Getting Help
- Issues: Report bugs or request features on GitHub Issues
- Discussions: Ask questions on GitHub Discussions
- Discord: Join our Discord server for real-time help
- Documentation: Detailed API docs are available on docs.rs
When reporting issues, please include:
- Your Bevy version
- Operating system and version
- Minimal code example that reproduces the problem
- Console output or error messages
Supported Versions
| bevy | bevy_perf_hud |
|---|---|
| 0.16 | 0.1.1 |
License
Dual-licensed under either the MIT License or Apache License 2.0.
Acknowledgements
- Bevy Engine for providing the ECS/game-engine foundation.
bevy_diagnosticandSystemInformationDiagnosticsPluginfor the metrics that power the HUD.
Looking for the Chinese documentation? See README_CN.md.