bevy_diagnostic/
lib.rs

1#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
2#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3#![forbid(unsafe_code)]
4#![doc(
5    html_logo_url = "https://bevyengine.org/assets/icon.png",
6    html_favicon_url = "https://bevyengine.org/assets/icon.png"
7)]
8#![no_std]
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
14#[cfg(feature = "std")]
15extern crate std;
16
17extern crate alloc;
18
19mod diagnostic;
20mod entity_count_diagnostics_plugin;
21mod frame_count_diagnostics_plugin;
22mod frame_time_diagnostics_plugin;
23mod log_diagnostics_plugin;
24#[cfg(feature = "sysinfo_plugin")]
25mod system_information_diagnostics_plugin;
26
27pub use diagnostic::*;
28
29pub use entity_count_diagnostics_plugin::EntityCountDiagnosticsPlugin;
30pub use frame_count_diagnostics_plugin::{update_frame_count, FrameCount, FrameCountPlugin};
31pub use frame_time_diagnostics_plugin::FrameTimeDiagnosticsPlugin;
32pub use log_diagnostics_plugin::LogDiagnosticsPlugin;
33#[cfg(feature = "sysinfo_plugin")]
34pub use system_information_diagnostics_plugin::{SystemInfo, SystemInformationDiagnosticsPlugin};
35
36use bevy_app::prelude::*;
37
38/// Adds core diagnostics resources to an App.
39#[derive(Default)]
40pub struct DiagnosticsPlugin;
41
42impl Plugin for DiagnosticsPlugin {
43    fn build(&self, app: &mut App) {
44        app.init_resource::<DiagnosticsStore>();
45
46        #[cfg(feature = "sysinfo_plugin")]
47        app.init_resource::<SystemInfo>();
48    }
49}
50
51/// Default max history length for new diagnostics.
52pub const DEFAULT_MAX_HISTORY_LENGTH: usize = 120;