rapier2d/counters/
stages_counters.rsuse crate::counters::Timer;
use std::fmt::{Display, Formatter, Result};
#[derive(Default, Clone, Copy)]
pub struct StagesCounters {
pub update_time: Timer,
pub collision_detection_time: Timer,
pub island_construction_time: Timer,
pub solver_time: Timer,
pub ccd_time: Timer,
pub query_pipeline_time: Timer,
pub user_changes: Timer,
}
impl StagesCounters {
pub fn new() -> Self {
StagesCounters {
update_time: Timer::new(),
collision_detection_time: Timer::new(),
island_construction_time: Timer::new(),
solver_time: Timer::new(),
ccd_time: Timer::new(),
query_pipeline_time: Timer::new(),
user_changes: Timer::new(),
}
}
pub fn reset(&mut self) {
self.update_time.reset();
self.collision_detection_time.reset();
self.island_construction_time.reset();
self.solver_time.reset();
self.ccd_time.reset();
self.query_pipeline_time.reset();
self.user_changes.reset();
}
}
impl Display for StagesCounters {
fn fmt(&self, f: &mut Formatter) -> Result {
writeln!(f, "Update time: {}", self.update_time)?;
writeln!(
f,
"Collision detection time: {}",
self.collision_detection_time
)?;
writeln!(
f,
"Island construction time: {}",
self.island_construction_time
)?;
writeln!(f, "Solver time: {}", self.solver_time)?;
writeln!(f, "CCD time: {}", self.ccd_time)?;
writeln!(f, "Query pipeline time: {}", self.query_pipeline_time)?;
writeln!(f, "User changes time: {}", self.user_changes)
}
}