aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/BenchTimer.h
diff options
context:
space:
mode:
authorGravatar Bram de Jong <bram.dejong@samplesumo.com>2011-09-26 14:39:23 +0100
committerGravatar Bram de Jong <bram.dejong@samplesumo.com>2011-09-26 14:39:23 +0100
commit961a825b97df33c2597767195f61cc569d3af7d7 (patch)
tree4fc7793583a3af011c3c883f250950fb069b2bac /bench/BenchTimer.h
parent9bba0e7ba123155d7a639d7c1bd5675dce91ae6f (diff)
Add method which returns worst time (and make some methods const).
Diffstat (limited to 'bench/BenchTimer.h')
-rw-r--r--bench/BenchTimer.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/bench/BenchTimer.h b/bench/BenchTimer.h
index 5ecab12e5..7138bd91c 100644
--- a/bench/BenchTimer.h
+++ b/bench/BenchTimer.h
@@ -79,6 +79,7 @@ public:
inline void reset()
{
m_bests.fill(1e9);
+ m_worsts.fill(0);
m_totals.setZero();
}
inline void start()
@@ -92,35 +93,45 @@ public:
m_times[REAL_TIMER] = getRealTime() - m_starts[REAL_TIMER];
#if EIGEN_VERSION_AT_LEAST(2,90,0)
m_bests = m_bests.cwiseMin(m_times);
+ m_worsts = m_worsts.cwiseMax(m_times);
#else
m_bests(0) = std::min(m_bests(0),m_times(0));
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
m_totals += m_times;
}
/** 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 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 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.
*/
- inline double total(int TIMER = CPU_TIMER)
+ inline double total(int TIMER = CPU_TIMER) const
{
return m_totals[TIMER];
}
- inline double getCpuTime()
+ inline double getCpuTime() const
{
#ifdef _WIN32
LARGE_INTEGER query_ticks;
@@ -135,7 +146,7 @@ public:
#endif
}
- inline double getRealTime()
+ inline double getRealTime() const
{
#ifdef _WIN32
SYSTEMTIME st;
@@ -157,8 +168,11 @@ protected:
Vector2d m_starts;
Vector2d m_times;
Vector2d m_bests;
+ Vector2d m_worsts;
Vector2d m_totals;
+public:
+ EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
#define BENCH(TIMER,TRIES,REP,CODE) { \