From 961a825b97df33c2597767195f61cc569d3af7d7 Mon Sep 17 00:00:00 2001 From: Bram de Jong Date: Mon, 26 Sep 2011 14:39:23 +0100 Subject: Add method which returns worst time (and make some methods const). --- bench/BenchTimer.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'bench/BenchTimer.h') 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) { \ -- cgit v1.2.3