use crate::counters::Timer;
use std::fmt::{Display, Formatter, Result};
#[derive(Default, Clone, Copy)]
pub struct StagesCounters {
pub collision_detection_time: Timer,
pub solver_time: Timer,
}
impl StagesCounters {
pub fn new() -> Self {
StagesCounters {
collision_detection_time: Timer::new(),
solver_time: Timer::new(),
}
}
pub fn enable(&mut self) {
self.collision_detection_time.enable();
self.solver_time.enable();
}
pub fn disable(&mut self) {
self.collision_detection_time.disable();
self.solver_time.disable();
}
pub fn reset(&mut self) {
self.collision_detection_time.reset();
self.solver_time.reset();
}
}
impl Display for StagesCounters {
fn fmt(&self, f: &mut Formatter) -> Result {
writeln!(
f,
"Collision detection time: {}",
self.collision_detection_time
)?;
writeln!(f, "Solver time: {}", self.solver_time)
}
}