bevy_diagnostic/
lib.rs

1// FIXME(15321): solve CI failures, then replace with `#![expect()]`.
2#![allow(missing_docs, reason = "Not all docs are written yet, see #3492.")]
3#![cfg_attr(docsrs, feature(doc_auto_cfg))]
4#![forbid(unsafe_code)]
5#![doc(
6    html_logo_url = "https://bevyengine.org/assets/icon.png",
7    html_favicon_url = "https://bevyengine.org/assets/icon.png"
8)]
9
10//! This crate provides a straightforward solution for integrating diagnostics in the [Bevy game engine](https://bevyengine.org/).
11//! It allows users to easily add diagnostic functionality to their Bevy applications, enhancing
12//! their ability to monitor and optimize their game's.
13
14extern crate alloc;
15
16mod diagnostic;
17mod entity_count_diagnostics_plugin;
18mod frame_time_diagnostics_plugin;
19mod log_diagnostics_plugin;
20#[cfg(feature = "sysinfo_plugin")]
21mod system_information_diagnostics_plugin;
22
23pub use diagnostic::*;
24
25pub use entity_count_diagnostics_plugin::EntityCountDiagnosticsPlugin;
26pub use frame_time_diagnostics_plugin::FrameTimeDiagnosticsPlugin;
27pub use log_diagnostics_plugin::LogDiagnosticsPlugin;
28#[cfg(feature = "sysinfo_plugin")]
29pub use system_information_diagnostics_plugin::{SystemInfo, SystemInformationDiagnosticsPlugin};
30
31use bevy_app::prelude::*;
32
33/// Adds core diagnostics resources to an App.
34#[derive(Default)]
35pub struct DiagnosticsPlugin;
36
37impl Plugin for DiagnosticsPlugin {
38    fn build(&self, app: &mut App) {
39        app.init_resource::<DiagnosticsStore>();
40
41        #[cfg(feature = "sysinfo_plugin")]
42        app.init_resource::<SystemInfo>();
43    }
44}
45
46/// Default max history length for new diagnostics.
47pub const DEFAULT_MAX_HISTORY_LENGTH: usize = 120;