Skip to content

Commit

Permalink
updated diagnostics plugins to use raw time measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
maniwani committed Mar 4, 2022
1 parent 2ea1c84 commit e0335c2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ impl FrameTimeDiagnosticsPlugin {
state.frame_count += 1.0;
diagnostics.add_measurement(Self::FRAME_COUNT, state.frame_count);

if time.delta_seconds_f64() == 0.0 {
let frame_time = time.raw_delta_seconds_f64();
if frame_time == 0.0 {
return;
}

diagnostics.add_measurement(Self::FRAME_TIME, time.delta_seconds_f64());
diagnostics.add_measurement(Self::FRAME_TIME, frame_time);
if let Some(fps) = diagnostics
.get(Self::FRAME_TIME)
.and_then(|frame_time_diagnostic| {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_diagnostic/src/log_diagnostics_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl LogDiagnosticsPlugin {
time: Res<Time>,
diagnostics: Res<Diagnostics>,
) {
if state.timer.tick(time.delta()).finished() {
if state.timer.tick(time.raw_delta()).finished() {
if let Some(ref filter) = state.filter {
for diagnostic in filter.iter().map(|id| diagnostics.get(*id).unwrap()) {
Self::log_diagnostic(diagnostic);
Expand All @@ -103,7 +103,7 @@ impl LogDiagnosticsPlugin {
time: Res<Time>,
diagnostics: Res<Diagnostics>,
) {
if state.timer.tick(time.delta()).finished() {
if state.timer.tick(time.raw_delta()).finished() {
if let Some(ref filter) = state.filter {
for diagnostic in filter.iter().map(|id| diagnostics.get(*id).unwrap()) {
debug!("{:#?}\n", diagnostic);
Expand Down
2 changes: 1 addition & 1 deletion examples/ui/text_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ fn change_text_system(
}
}

let mut frame_time = time.delta_seconds_f64();
let mut frame_time = time.raw_delta_seconds_f64();
if let Some(frame_time_diagnostic) = diagnostics.get(FrameTimeDiagnosticsPlugin::FRAME_TIME)
{
if let Some(frame_time_avg) = frame_time_diagnostic.average() {
Expand Down
4 changes: 2 additions & 2 deletions examples/wasm/winit_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ fn counter(mut state: Local<CounterState>, time: Res<Time>) {
info!(
"tick {} @ {:?} [Δ{}]",
state.count,
time.elapsed_since_startup(),
time.delta_seconds()
time.raw_elapsed_since_startup(),
time.raw_delta_seconds()
);
}
state.count += 1;
Expand Down

0 comments on commit e0335c2

Please sign in to comment.