print average fps and smooth out average a little bit
This commit is contained in:
parent
e65fe0e736
commit
8bc0eb45ee
@ -19,8 +19,8 @@ impl FrameTimeDiagnosticsPlugin {
|
|||||||
DiagnosticId::from_u128(54021991829115352065418785002088010276);
|
DiagnosticId::from_u128(54021991829115352065418785002088010276);
|
||||||
|
|
||||||
pub fn setup_system(mut diagnostics: ResMut<Diagnostics>) {
|
pub fn setup_system(mut diagnostics: ResMut<Diagnostics>) {
|
||||||
diagnostics.add(Diagnostic::new(Self::FRAME_TIME, "frame_time", 10));
|
diagnostics.add(Diagnostic::new(Self::FRAME_TIME, "frame_time", 20));
|
||||||
diagnostics.add(Diagnostic::new(Self::FPS, "fps", 10));
|
diagnostics.add(Diagnostic::new(Self::FPS, "fps", 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn diagnostic_system(mut diagnostics: ResMut<Diagnostics>, time: Res<Time>) {
|
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>) {
|
fn text_update_system(diagnostics: Res<Diagnostics>, mut label: ComMut<Label>) {
|
||||||
if let Some(fps) = diagnostics.get_measurement(FrameTimeDiagnosticsPlugin::FPS) {
|
if let Some(fps) = diagnostics.get(FrameTimeDiagnosticsPlugin::FPS) {
|
||||||
label.text = format!("FPS: {}", fps.value.round());
|
if let Some(average) = fps.average() {
|
||||||
|
label.text = format!("FPS: {}", average.round());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user