rapier2d/counters/
stages_counters.rs1use crate::counters::Timer;
2use std::fmt::{Display, Formatter, Result};
3
4#[derive(Default, Clone, Copy)]
6pub struct StagesCounters {
7 pub update_time: Timer,
9 pub collision_detection_time: Timer,
11 pub island_construction_time: Timer,
13 pub solver_time: Timer,
15 pub ccd_time: Timer,
17 pub user_changes: Timer,
19}
20
21impl StagesCounters {
22 pub fn new() -> Self {
24 StagesCounters {
25 update_time: Timer::new(),
26 collision_detection_time: Timer::new(),
27 island_construction_time: Timer::new(),
28 solver_time: Timer::new(),
29 ccd_time: Timer::new(),
30 user_changes: Timer::new(),
31 }
32 }
33
34 pub fn reset(&mut self) {
36 self.update_time.reset();
37 self.collision_detection_time.reset();
38 self.island_construction_time.reset();
39 self.solver_time.reset();
40 self.ccd_time.reset();
41 self.user_changes.reset();
42 }
43}
44
45impl Display for StagesCounters {
46 fn fmt(&self, f: &mut Formatter) -> Result {
47 writeln!(f, "Update time: {}", self.update_time)?;
48 writeln!(
49 f,
50 "Collision detection time: {}",
51 self.collision_detection_time
52 )?;
53 writeln!(
54 f,
55 "Island construction time: {}",
56 self.island_construction_time
57 )?;
58 writeln!(f, "Solver time: {}", self.solver_time)?;
59 writeln!(f, "CCD time: {}", self.ccd_time)?;
60 writeln!(f, "User changes time: {}", self.user_changes)
61 }
62}