Timer: force measures to be retrieved even if parallel.doMeasure() isn't set.

This commit is contained in:
Benjamin BOUVIER 2012-10-01 23:26:21 -04:00
commit bd9767a05d

View file

@ -205,6 +205,14 @@ class eoTimerStat
{ {
public: public:
/**
* @brief Initializes a timer stat object.
*/
eoTimerStat() : _forceDoMeasure(false)
{
// empty
}
/** /**
* @brief Statistic related to a key (name). * @brief Statistic related to a key (name).
* *
@ -274,6 +282,14 @@ class eoTimerStat
} }
# endif # endif
/**
* @brief Forces the measures to be retrieved.
*/
void forceDoMeasure()
{
_forceDoMeasure = true;
}
/** /**
* @brief Starts a new measure for the given key. * @brief Starts a new measure for the given key.
* *
@ -284,7 +300,7 @@ class eoTimerStat
*/ */
void start( const std::string & key ) void start( const std::string & key )
{ {
if( eo::parallel.doMeasure() ) if( eo::parallel.doMeasure() or _forceDoMeasure )
{ {
_timers[ key ].restart(); _timers[ key ].restart();
} }
@ -302,7 +318,7 @@ class eoTimerStat
*/ */
void stop( const std::string& key ) void stop( const std::string& key )
{ {
if( eo::parallel.doMeasure() ) if( eo::parallel.doMeasure() or _forceDoMeasure )
{ {
Stat & s = _stats[ key ]; Stat & s = _stats[ key ];
eoTimer & t = _timers[ key ]; eoTimer & t = _timers[ key ];
@ -333,6 +349,8 @@ class eoTimerStat
std::map< std::string, Stat > _stats; std::map< std::string, Stat > _stats;
// Timers map: links a key to its timer. // Timers map: links a key to its timer.
std::map< std::string, eoTimer > _timers; std::map< std::string, eoTimer > _timers;
// boolean to force the retrieval of statistics
bool _forceDoMeasure;
}; };
# endif // __TIMER_H__ # endif // __TIMER_H__