rapier2d/counters/
stages_counters.rs1use crate::counters::Timer;
2use core::fmt::{Display, Formatter, Result};
3
4#[derive(Default, Clone, Copy, Debug)]
6pub struct StagesCounters {
7 pub update_time: Timer,
9 pub collision_detection_time: Timer,
11 pub island_construction_time: Timer,
13 pub island_constraints_collection_time: Timer,
19 pub solver_time: Timer,
21 pub ccd_time: Timer,
23 pub user_changes: Timer,
25}
26
27impl StagesCounters {
28 pub fn new() -> Self {
30 StagesCounters {
31 update_time: Timer::new(),
32 collision_detection_time: Timer::new(),
33 island_construction_time: Timer::new(),
34 island_constraints_collection_time: Timer::new(),
35 solver_time: Timer::new(),
36 ccd_time: Timer::new(),
37 user_changes: Timer::new(),
38 }
39 }
40
41 pub fn reset(&mut self) {
43 self.update_time.reset();
44 self.collision_detection_time.reset();
45 self.island_construction_time.reset();
46 self.island_constraints_collection_time.reset();
47 self.solver_time.reset();
48 self.ccd_time.reset();
49 self.user_changes.reset();
50 }
51}
52
53impl Display for StagesCounters {
54 fn fmt(&self, f: &mut Formatter) -> Result {
55 writeln!(f, "Update time: {}", self.update_time)?;
56 writeln!(
57 f,
58 "Collision detection time: {}",
59 self.collision_detection_time
60 )?;
61 writeln!(
62 f,
63 "Island construction time: {}",
64 self.island_construction_time
65 )?;
66 writeln!(
67 f,
68 "Constraints maintenance time: {}",
69 self.island_constraints_collection_time
70 )?;
71 writeln!(f, "Solver time: {}", self.solver_time)?;
72 writeln!(f, "CCD time: {}", self.ccd_time)?;
73 writeln!(f, "User changes time: {}", self.user_changes)
74 }
75}