diff --git a/include/crocoddyl/core/utils/stop-watch.hpp b/include/crocoddyl/core/utils/stop-watch.hpp index b6ba51c49..02bc53e8b 100644 --- a/include/crocoddyl/core/utils/stop-watch.hpp +++ b/include/crocoddyl/core/utils/stop-watch.hpp @@ -163,8 +163,16 @@ class Stopwatch { Watcher(Stopwatch &_w, std::string _n, PerformanceData *_p) : w(_w), n(_n), p(_p) {} - void start(); - void stop(); + inline void start() { + if (w.profiler_active) _start(); + } + inline void stop() { + if (w.profiler_active) _stop(); + } + + private: + void _start(); + void _stop(); }; /** @brief Constructor */ @@ -180,7 +188,7 @@ class Stopwatch { void disable_profiler(); /** @brief Return if the profiler is enable or disable **/ - bool profiler_status(); + inline bool profiler_status() { return profiler_active; } /** @brief Tells if a performance with a certain ID exists */ bool performance_exists(std::string perf_name); diff --git a/src/core/utils/stop-watch.cpp b/src/core/utils/stop-watch.cpp index 3be8fec2e..974af96d2 100644 --- a/src/core/utils/stop-watch.cpp +++ b/src/core/utils/stop-watch.cpp @@ -56,8 +56,6 @@ void Stopwatch::enable_profiler() { profiler_active = true; } void Stopwatch::disable_profiler() { profiler_active = false; } -bool Stopwatch::profiler_status() { return profiler_active; } - void Stopwatch::set_mode(StopwatchMode new_mode) { mode = new_mode; } bool Stopwatch::performance_exists(string perf_name) { @@ -347,7 +345,7 @@ Stopwatch::Watcher Stopwatch::watcher(const string& perf_name) { return Watcher(*this, perf_name, perf_info); } -void Stopwatch::Watcher::start() { +void Stopwatch::Watcher::_start() { if (!w.profiler_active) return; if (p == nullptr) { @@ -358,7 +356,7 @@ void Stopwatch::Watcher::start() { p->paused = false; } -void Stopwatch::Watcher::stop() { +void Stopwatch::Watcher::_stop() { if (!w.profiler_active || (p == nullptr)) return; long double clock_end = w.take_time();