aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Crozet <sebcrozet@dimforge.com>2022-05-31 11:49:36 +0200
committerSébastien Crozet <sebcrozet@dimforge.com>2022-05-31 11:49:36 +0200
commit10ca3474e67d53d3d1ec306dd2973d95043ba666 (patch)
tree73258de799a6904c16d5f027dcd8d3c163387298 /src
parentfb1bfc762c89cd8c5bd745a82998c1662a1bf196 (diff)
downloadrapier-10ca3474e67d53d3d1ec306dd2973d95043ba666.tar.gz
rapier-10ca3474e67d53d3d1ec306dd2973d95043ba666.tar.bz2
rapier-10ca3474e67d53d3d1ec306dd2973d95043ba666.zip
Make the`instant` dependency optional, behind a `profiler` cargo feature
Diffstat (limited to 'src')
-rw-r--r--src/counters/timer.rs22
-rw-r--r--src/pipeline/physics_pipeline.rs2
2 files changed, 17 insertions, 7 deletions
diff --git a/src/counters/timer.rs b/src/counters/timer.rs
index fd25063..bc0397d 100644
--- a/src/counters/timer.rs
+++ b/src/counters/timer.rs
@@ -4,6 +4,7 @@ use std::fmt::{Display, Error, Formatter};
#[derive(Copy, Clone, Debug, Default)]
pub struct Timer {
time: f64,
+ #[allow(dead_code)] // The field isn’t used if the `profiler` feature isn’t enabled.
start: Option<f64>,
}
@@ -23,21 +24,30 @@ impl Timer {
/// Start the timer.
pub fn start(&mut self) {
- self.time = 0.0;
- self.start = Some(instant::now());
+ #[cfg(feature = "profiler")]
+ {
+ self.time = 0.0;
+ self.start = Some(instant::now());
+ }
}
/// Pause the timer.
pub fn pause(&mut self) {
- if let Some(start) = self.start {
- self.time += instant::now() - start;
+ #[cfg(feature = "profiler")]
+ {
+ if let Some(start) = self.start {
+ self.time += instant::now() - start;
+ }
+ self.start = None;
}
- self.start = None;
}
/// Resume the timer.
pub fn resume(&mut self) {
- self.start = Some(instant::now());
+ #[cfg(feature = "profiler")]
+ {
+ self.start = Some(instant::now());
+ }
}
/// The measured time between the last `.start()` and `.pause()` calls.
diff --git a/src/pipeline/physics_pipeline.rs b/src/pipeline/physics_pipeline.rs
index 012f40f..19749be 100644
--- a/src/pipeline/physics_pipeline.rs
+++ b/src/pipeline/physics_pipeline.rs
@@ -54,7 +54,7 @@ impl PhysicsPipeline {
/// Initializes a new physics pipeline.
pub fn new() -> PhysicsPipeline {
PhysicsPipeline {
- counters: Counters::new(false),
+ counters: Counters::new(true),
solvers: Vec::new(),
manifold_indices: Vec::new(),
joint_constraint_indices: Vec::new(),