1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use crate::counters::Timer;
use core::fmt::{Display, Formatter, Result};
/// Performance counters related to each stage of the time step.
#[derive(Default, Clone, Copy, Debug)]
pub struct StagesCounters {
/// Time spent for updating the kinematic and dynamics of every body.
pub update_time: Timer,
/// Total time spent for the collision detection (including both broad- and narrow- phases).
pub collision_detection_time: Timer,
/// Time spent for the computation of collision island and body activation/deactivation (sleeping).
pub island_construction_time: Timer,
/// Time spent maintaining the persistent solver-facing structures (solver
/// contact graph reconciliation for the pairs that changed this step,
/// frontier solver-body slots, force-event pair list). O(changed pairs) —
/// the solvers consume the persistent buckets directly, so there is no
/// per-step constraints-collection pass anymore.
pub island_constraints_collection_time: Timer,
/// Total time spent for the constraints resolution and position update.t
pub solver_time: Timer,
/// Total time spent for CCD and CCD resolution.
pub ccd_time: Timer,
/// Total time spent propagating user changes.
pub user_changes: Timer,
}
impl StagesCounters {
/// Create a new counter initialized to zero.
pub fn new() -> Self {
StagesCounters {
update_time: Timer::new(),
collision_detection_time: Timer::new(),
island_construction_time: Timer::new(),
island_constraints_collection_time: Timer::new(),
solver_time: Timer::new(),
ccd_time: Timer::new(),
user_changes: Timer::new(),
}
}
/// Resets all the counters and timers.
pub fn reset(&mut self) {
self.update_time.reset();
self.collision_detection_time.reset();
self.island_construction_time.reset();
self.island_constraints_collection_time.reset();
self.solver_time.reset();
self.ccd_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,
"Constraints maintenance time: {}",
self.island_constraints_collection_time
)?;
writeln!(f, "Solver time: {}", self.solver_time)?;
writeln!(f, "CCD time: {}", self.ccd_time)?;
writeln!(f, "User changes time: {}", self.user_changes)
}
}