From 27fe2e88bd77a356c8be5db050a9021495c9039f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 13 Jul 2025 00:40:36 +0200 Subject: [PATCH 1/2] Update `sysinfo` version to `0.36.0` (#20084) Some bugfixes and new API additions. --- crates/bevy_diagnostic/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_diagnostic/Cargo.toml b/crates/bevy_diagnostic/Cargo.toml index 424ca67437..a1803151fc 100644 --- a/crates/bevy_diagnostic/Cargo.toml +++ b/crates/bevy_diagnostic/Cargo.toml @@ -71,14 +71,14 @@ log = { version = "0.4", default-features = false } # macOS [target.'cfg(all(target_os="macos"))'.dependencies] # Some features of sysinfo are not supported by apple. This will disable those features on apple devices -sysinfo = { version = "0.35.0", optional = true, default-features = false, features = [ +sysinfo = { version = "0.36.0", optional = true, default-features = false, features = [ "apple-app-store", "system", ] } # Only include when on linux/windows/android/freebsd [target.'cfg(any(target_os = "linux", target_os = "windows", target_os = "android", target_os = "freebsd"))'.dependencies] -sysinfo = { version = "0.35.0", optional = true, default-features = false, features = [ +sysinfo = { version = "0.36.0", optional = true, default-features = false, features = [ "system", ] } From 1525dff7ada14714b35c8908381d534a7833faa3 Mon Sep 17 00:00:00 2001 From: onbjerg Date: Sun, 13 Jul 2025 01:00:38 +0200 Subject: [PATCH 2/2] Add `max_history_length` to `EntityCountDiagnosticsPlugin` (#20085) # Objective I was building out a diagnostics panel in egui when I noticed that I could specify the max history length for the `FrameTimeDiagnosticsPlugin`, but not for the `EntityCountDiagnosticsPlugin`. The objective was to harmonize the two, making the diagnostic history length configurable for both. ## Solution I added a `EntityCountDiagnosticsPlugin::new`, and a `Default` impl that matches `FrameTimeDiagnosticsPlugin`. This is a breaking change, given the plugin had no fields previously. ## Testing I did not test this. --- .../src/entity_count_diagnostics_plugin.rs | 29 +++++++++++++++---- examples/diagnostics/log_diagnostics.rs | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/crates/bevy_diagnostic/src/entity_count_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/entity_count_diagnostics_plugin.rs index b20a82bf6c..1de4f4c029 100644 --- a/crates/bevy_diagnostic/src/entity_count_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/entity_count_diagnostics_plugin.rs @@ -1,20 +1,39 @@ use bevy_app::prelude::*; use bevy_ecs::entity::Entities; -use crate::{Diagnostic, DiagnosticPath, Diagnostics, RegisterDiagnostic}; +use crate::{ + Diagnostic, DiagnosticPath, Diagnostics, RegisterDiagnostic, DEFAULT_MAX_HISTORY_LENGTH, +}; /// Adds "entity count" diagnostic to an App. /// /// # See also /// /// [`LogDiagnosticsPlugin`](crate::LogDiagnosticsPlugin) to output diagnostics to the console. -#[derive(Default)] -pub struct EntityCountDiagnosticsPlugin; +pub struct EntityCountDiagnosticsPlugin { + /// The total number of values to keep. + pub max_history_length: usize, +} + +impl Default for EntityCountDiagnosticsPlugin { + fn default() -> Self { + Self::new(DEFAULT_MAX_HISTORY_LENGTH) + } +} + +impl EntityCountDiagnosticsPlugin { + /// Creates a new `EntityCountDiagnosticsPlugin` with the specified `max_history_length`. + pub fn new(max_history_length: usize) -> Self { + Self { max_history_length } + } +} impl Plugin for EntityCountDiagnosticsPlugin { fn build(&self, app: &mut App) { - app.register_diagnostic(Diagnostic::new(Self::ENTITY_COUNT)) - .add_systems(Update, Self::diagnostic_system); + app.register_diagnostic( + Diagnostic::new(Self::ENTITY_COUNT).with_max_history_length(self.max_history_length), + ) + .add_systems(Update, Self::diagnostic_system); } } diff --git a/examples/diagnostics/log_diagnostics.rs b/examples/diagnostics/log_diagnostics.rs index 0e00e69ccd..1a36f9a1f2 100644 --- a/examples/diagnostics/log_diagnostics.rs +++ b/examples/diagnostics/log_diagnostics.rs @@ -33,7 +33,7 @@ fn main() { // Adds frame time, FPS and frame count diagnostics. FrameTimeDiagnosticsPlugin::default(), // Adds an entity count diagnostic. - EntityCountDiagnosticsPlugin, + EntityCountDiagnosticsPlugin::default(), // Adds cpu and memory usage diagnostics for systems and the entire game process. SystemInformationDiagnosticsPlugin, // Forwards various diagnostics from the render app to the main app.