From 24ea6c4d303e34161282cf9cd9469c779b58cacc Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 29 Jun 2021 09:25:18 -0600 Subject: [PATCH] make it possible to debug one of the RAII TimingStats objects --- libs/pbd/pbd/timing.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/pbd/pbd/timing.h b/libs/pbd/pbd/timing.h index 303727ab9f..492fd0e52c 100644 --- a/libs/pbd/pbd/timing.h +++ b/libs/pbd/pbd/timing.h @@ -19,6 +19,8 @@ #ifndef __libpbd_timing_h__ #define __libpbd_timing_h__ +#include + #include #include @@ -116,6 +118,9 @@ public: return elapsed () / 1000; } + microseconds_t start_time() const { return m_start_val; } + microseconds_t last_time() const { return m_last_val; } + protected: microseconds_t m_start_val; microseconds_t m_last_val; @@ -229,9 +234,12 @@ private: class LIBPBD_API TimerRAII { public: - TimerRAII (TimingStats& ts) : stats (ts) { stats.start(); } - ~TimerRAII() { stats.update(); } + TimerRAII (TimingStats& ts, bool dbg = false) : stats (ts), debug (dbg) { stats.start(); if (debug) std::cout << "Timer @ " << &stats << " start at " << stats.start_time() << std::endl;} + ~TimerRAII() { stats.update(); if (debug) std::cout << "Timer @ " << &stats << " stamp " << stats.last_time() << std::endl; } TimingStats& stats; + + private: + bool debug; }; /** Reverse semantics from TimerRAII. This starts the timer at scope exit,