Add method which returns worst time (and make some methods const).

This commit is contained in:
Bram de Jong 2011-09-26 14:39:23 +01:00
parent 9bba0e7ba1
commit 961a825b97

View File

@ -79,6 +79,7 @@ public:
inline void reset() inline void reset()
{ {
m_bests.fill(1e9); m_bests.fill(1e9);
m_worsts.fill(0);
m_totals.setZero(); m_totals.setZero();
} }
inline void start() inline void start()
@ -92,35 +93,45 @@ public:
m_times[REAL_TIMER] = getRealTime() - m_starts[REAL_TIMER]; m_times[REAL_TIMER] = getRealTime() - m_starts[REAL_TIMER];
#if EIGEN_VERSION_AT_LEAST(2,90,0) #if EIGEN_VERSION_AT_LEAST(2,90,0)
m_bests = m_bests.cwiseMin(m_times); m_bests = m_bests.cwiseMin(m_times);
m_worsts = m_worsts.cwiseMax(m_times);
#else #else
m_bests(0) = std::min(m_bests(0),m_times(0)); m_bests(0) = std::min(m_bests(0),m_times(0));
m_bests(1) = std::min(m_bests(1),m_times(1)); m_bests(1) = std::min(m_bests(1),m_times(1));
m_worsts(0) = std::max(m_worsts(0),m_times(0));
m_worsts(1) = std::max(m_worsts(1),m_times(1));
#endif #endif
m_totals += m_times; m_totals += m_times;
} }
/** Return the elapsed time in seconds between the last start/stop pair /** Return the elapsed time in seconds between the last start/stop pair
*/ */
inline double value(int TIMER = CPU_TIMER) inline double value(int TIMER = CPU_TIMER) const
{ {
return m_times[TIMER]; return m_times[TIMER];
} }
/** Return the best elapsed time in seconds /** Return the best elapsed time in seconds
*/ */
inline double best(int TIMER = CPU_TIMER) inline double best(int TIMER = CPU_TIMER) const
{ {
return m_bests[TIMER]; return m_bests[TIMER];
} }
/** Return the worst elapsed time in seconds
*/
inline double worst(int TIMER = CPU_TIMER) const
{
return m_worsts[TIMER];
}
/** Return the total elapsed time in seconds. /** Return the total elapsed time in seconds.
*/ */
inline double total(int TIMER = CPU_TIMER) inline double total(int TIMER = CPU_TIMER) const
{ {
return m_totals[TIMER]; return m_totals[TIMER];
} }
inline double getCpuTime() inline double getCpuTime() const
{ {
#ifdef _WIN32 #ifdef _WIN32
LARGE_INTEGER query_ticks; LARGE_INTEGER query_ticks;
@ -135,7 +146,7 @@ public:
#endif #endif
} }
inline double getRealTime() inline double getRealTime() const
{ {
#ifdef _WIN32 #ifdef _WIN32
SYSTEMTIME st; SYSTEMTIME st;
@ -157,8 +168,11 @@ protected:
Vector2d m_starts; Vector2d m_starts;
Vector2d m_times; Vector2d m_times;
Vector2d m_bests; Vector2d m_bests;
Vector2d m_worsts;
Vector2d m_totals; Vector2d m_totals;
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
}; };
#define BENCH(TIMER,TRIES,REP,CODE) { \ #define BENCH(TIMER,TRIES,REP,CODE) { \