Skip to content

Commit

Permalink
ECS now also issue a debug warning if timings are too long. Also redu…
Browse files Browse the repository at this point in the history
…ced physics states log level.
  • Loading branch information
MeFisto94 committed Jan 25, 2025
1 parent eb54c19 commit 4791628
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/entity/systems/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use crate::entity::systems::rendering_system::RenderingSystem;
use crate::entity::systems::spline_walker_system::SplineWalkerSystem;
use crate::game::application::GameApplication;
use crate::io::mpq::loader::MPQLoader;
use log::debug;
use std::sync::{Arc, Weak};
use std::time::Instant;

pub struct Systems {
display_id_resolver_system: DisplayIdResolverSystem,
Expand All @@ -21,8 +23,15 @@ impl Systems {
}

pub fn update(&self, app: &GameApplication, delta_time: f32) {
let pre_systems = Instant::now();

self.spline_walker_system.update(app, delta_time);
self.display_id_resolver_system.update(app);
self.rendering_system.update(app);

let duration_systems = (Instant::now() - pre_systems).as_millis();
if duration_systems > 6 {
debug!("Systems update took too long: {:?} ms", duration_systems);
}
}
}
4 changes: 2 additions & 2 deletions src/rendering/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::rendering::rend3_backend::material::units::units_routine::UnitsRoutin
use crate::rendering::rend3_backend::{Rend3BackendConverter, gpu_loaders};
use glam::{Mat4, UVec2, Vec3A, Vec4};
use itertools::Itertools;
use log::{trace, warn};
use log::{debug, trace, warn};
use rend3::graph::RenderGraph;
use rend3::types::{
Camera, CameraProjection, Handedness, MaterialHandle, ObjectHandle, PresentMode, SampleCount, Texture,
Expand Down Expand Up @@ -118,7 +118,7 @@ impl RenderingApplication {

let duration_physics = (Instant::now() - pre_physics).as_millis();
if duration_physics > 6 {
warn!("Physics update took too long: {:?} ms", duration_physics);
debug!("Physics update took too long: {:?} ms", duration_physics);
}

if let Some(network) = app.network.as_ref() {
Expand Down

0 comments on commit 4791628

Please sign in to comment.