mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 06:00:20 +00:00
print average fps and smooth out average a little bit
This commit is contained in:
parent
e65fe0e736
commit
8bc0eb45ee
2 changed files with 6 additions and 4 deletions
|
@ -19,8 +19,8 @@ impl FrameTimeDiagnosticsPlugin {
|
|||
DiagnosticId::from_u128(54021991829115352065418785002088010276);
|
||||
|
||||
pub fn setup_system(mut diagnostics: ResMut<Diagnostics>) {
|
||||
diagnostics.add(Diagnostic::new(Self::FRAME_TIME, "frame_time", 10));
|
||||
diagnostics.add(Diagnostic::new(Self::FPS, "fps", 10));
|
||||
diagnostics.add(Diagnostic::new(Self::FRAME_TIME, "frame_time", 20));
|
||||
diagnostics.add(Diagnostic::new(Self::FPS, "fps", 20));
|
||||
}
|
||||
|
||||
pub fn diagnostic_system(mut diagnostics: ResMut<Diagnostics>, time: Res<Time>) {
|
||||
|
|
|
@ -13,8 +13,10 @@ fn main() {
|
|||
}
|
||||
|
||||
fn text_update_system(diagnostics: Res<Diagnostics>, mut label: ComMut<Label>) {
|
||||
if let Some(fps) = diagnostics.get_measurement(FrameTimeDiagnosticsPlugin::FPS) {
|
||||
label.text = format!("FPS: {}", fps.value.round());
|
||||
if let Some(fps) = diagnostics.get(FrameTimeDiagnosticsPlugin::FPS) {
|
||||
if let Some(average) = fps.average() {
|
||||
label.text = format!("FPS: {}", average.round());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue