mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 02:33:59 +08:00
Add method which returns worst time (and make some methods const).
This commit is contained in:
parent
9bba0e7ba1
commit
961a825b97
@ -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) { \
|
||||
|
Loading…
x
Reference in New Issue
Block a user