Skip to content

Commit

Permalink
changed diagnostics from seconds to milliseconds (bevyengine#5554)
Browse files Browse the repository at this point in the history
Co-authored-by: Alice Cecile <[email protected]>

# 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 <[email protected]>
Co-authored-by: McSpidey <[email protected]>
Co-authored-by: Carter Anderson <[email protected]>
  • Loading branch information
4 people authored and inodentry committed Aug 19, 2022
1 parent f5daa43 commit a943d5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl FrameTimeDiagnosticsPlugin {
DiagnosticId::from_u128(73441630925388532774622109383099159699);

pub fn setup_system(mut diagnostics: ResMut<Diagnostics>) {
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));
}
Expand All @@ -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());
}
Expand Down
5 changes: 2 additions & 3 deletions examples/ui/text_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit a943d5a

Please sign in to comment.