From bd9767a05d38edc3bd29af9741c548a0e2d5beef Mon Sep 17 00:00:00 2001 From: Benjamin BOUVIER Date: Mon, 1 Oct 2012 23:26:21 -0400 Subject: [PATCH] Timer: force measures to be retrieved even if parallel.doMeasure() isn't set. --- eo/src/utils/eoTimer.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/eo/src/utils/eoTimer.h b/eo/src/utils/eoTimer.h index fbf90c218..9f9371ddd 100644 --- a/eo/src/utils/eoTimer.h +++ b/eo/src/utils/eoTimer.h @@ -205,6 +205,14 @@ class eoTimerStat { public: + /** + * @brief Initializes a timer stat object. + */ + eoTimerStat() : _forceDoMeasure(false) + { + // empty + } + /** * @brief Statistic related to a key (name). * @@ -274,6 +282,14 @@ class eoTimerStat } # endif + /** + * @brief Forces the measures to be retrieved. + */ + void forceDoMeasure() + { + _forceDoMeasure = true; + } + /** * @brief Starts a new measure for the given key. * @@ -284,7 +300,7 @@ class eoTimerStat */ void start( const std::string & key ) { - if( eo::parallel.doMeasure() ) + if( eo::parallel.doMeasure() or _forceDoMeasure ) { _timers[ key ].restart(); } @@ -302,7 +318,7 @@ class eoTimerStat */ void stop( const std::string& key ) { - if( eo::parallel.doMeasure() ) + if( eo::parallel.doMeasure() or _forceDoMeasure ) { Stat & s = _stats[ key ]; eoTimer & t = _timers[ key ]; @@ -333,6 +349,8 @@ class eoTimerStat std::map< std::string, Stat > _stats; // Timers map: links a key to its timer. std::map< std::string, eoTimer > _timers; + // boolean to force the retrieval of statistics + bool _forceDoMeasure; }; # endif // __TIMER_H__