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 island_constraints_collection_time: Timer,
15 pub solver_time: Timer,
17 pub ccd_time: Timer,
19 pub user_changes: Timer,
21}
22
23impl StagesCounters {
24 pub fn new() -> Self {
26 StagesCounters {
27 update_time: Timer::new(),
28 collision_detection_time: Timer::new(),
29 island_construction_time: Timer::new(),
30 island_constraints_collection_time: Timer::new(),
31 solver_time: Timer::new(),
32 ccd_time: Timer::new(),
33 user_changes: Timer::new(),
34 }
35 }
36
37 pub fn reset(&mut self) {
39 self.update_time.reset();
40 self.collision_detection_time.reset();
41 self.island_construction_time.reset();
42 self.island_constraints_collection_time.reset();
43 self.solver_time.reset();
44 self.ccd_time.reset();
45 self.user_changes.reset();
46 }
47}
48
49impl Display for StagesCounters {
50 fn fmt(&self, f: &mut Formatter) -> Result {
51 writeln!(f, "Update time: {}", self.update_time)?;
52 writeln!(
53 f,
54 "Collision detection time: {}",
55 self.collision_detection_time
56 )?;
57 writeln!(
58 f,
59 "Island construction time: {}",
60 self.island_construction_time
61 )?;
62 writeln!(
63 f,
64 "Island construction time: {}",
65 self.island_constraints_collection_time
66 )?;
67 writeln!(f, "Solver time: {}", self.solver_time)?;
68 writeln!(f, "CCD time: {}", self.ccd_time)?;
69 writeln!(f, "User changes time: {}", self.user_changes)
70 }
71}