From 6b2e5d76e17bac1ba6ba86718804a0b6a51c4c06 Mon Sep 17 00:00:00 2001 From: McSpidey Date: Thu, 4 Aug 2022 22:27:14 +0000 Subject: [PATCH] changed diagnostics from seconds to milliseconds (#5554) Co-authored-by: Alice Cecile # Objective Change frametimediagnostic from seconds to milliseconds because this will always be less than one seconds and is the common diagnostic display unit for game engines. ## Solution - multiplied the existing value by 1000 --- ## Changelog Frametimes are now reported in milliseconds Co-authored-by: Syama Mishra <38512086+SyamaMishra@users.noreply.github.com> Co-authored-by: McSpidey Co-authored-by: Carter Anderson --- crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs | 4 ++-- examples/ui/text_debug.rs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs index bc07eaaad6887..68b73befbf295 100644 --- a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs @@ -27,7 +27,7 @@ impl FrameTimeDiagnosticsPlugin { DiagnosticId::from_u128(73441630925388532774622109383099159699); pub fn setup_system(mut diagnostics: ResMut) { - diagnostics.add(Diagnostic::new(Self::FRAME_TIME, "frame_time", 20).with_suffix("s")); + diagnostics.add(Diagnostic::new(Self::FRAME_TIME, "frame_time", 20).with_suffix("ms")); diagnostics.add(Diagnostic::new(Self::FPS, "fps", 20)); diagnostics.add(Diagnostic::new(Self::FRAME_COUNT, "frame_count", 1)); } @@ -46,7 +46,7 @@ impl FrameTimeDiagnosticsPlugin { return; } - diagnostics.add_measurement(Self::FRAME_TIME, || time.delta_seconds_f64()); + diagnostics.add_measurement(Self::FRAME_TIME, || time.delta_seconds_f64() * 1000.); diagnostics.add_measurement(Self::FPS, || 1.0 / time.delta_seconds_f64()); } diff --git a/examples/ui/text_debug.rs b/examples/ui/text_debug.rs index 4a56e72d518d1..8903f9b9d02d2 100644 --- a/examples/ui/text_debug.rs +++ b/examples/ui/text_debug.rs @@ -176,12 +176,11 @@ fn change_text_system( text.sections[0].value = format!( "This text changes in the bottom right - {:.1} fps, {:.3} ms/frame", - fps, - frame_time * 1000.0, + fps, frame_time, ); text.sections[2].value = format!("{:.1}", fps); - text.sections[4].value = format!("{:.3}", frame_time * 1000.0); + text.sections[4].value = format!("{:.3}", frame_time); } }