nphysics2d/counters/
solver_counters.rs1use crate::counters::Timer;
2use std::fmt::{Display, Formatter, Result};
3
4#[derive(Default, Clone, Copy)]
6pub struct SolverCounters {
7 pub nconstraints: usize,
9 pub ncontacts: usize,
11 pub velocity_resolution_time: Timer,
13 pub assembly_time: Timer,
15 pub velocity_update_time: Timer,
17 pub position_resolution_time: Timer,
19}
20
21impl SolverCounters {
22 pub fn new() -> Self {
24 SolverCounters {
25 nconstraints: 0,
26 ncontacts: 0,
27 assembly_time: Timer::new(),
28 velocity_resolution_time: Timer::new(),
29 velocity_update_time: Timer::new(),
30 position_resolution_time: Timer::new(),
31 }
32 }
33}
34
35impl Display for SolverCounters {
36 fn fmt(&self, f: &mut Formatter) -> Result {
37 writeln!(f, "Number of contacts: {}", self.ncontacts)?;
38 writeln!(f, "Number of constraints: {}", self.nconstraints)?;
39 writeln!(f, "Assembly time: {}", self.assembly_time)?;
40 writeln!(
41 f,
42 "Velocity resolution time: {}",
43 self.velocity_resolution_time
44 )?;
45 writeln!(f, "Velocity update time: {}", self.velocity_update_time)?;
46 writeln!(
47 f,
48 "Position resolution time: {}",
49 self.position_resolution_time
50 )
51 }
52}