11 #ifndef EIGEN_BENCH_TIMERR_H 12 #define EIGEN_BENCH_TIMERR_H 14 #if defined(_WIN32) || defined(__CYGWIN__) 17 # define EIGEN_BT_UNDEF_NOMINMAX 19 # ifndef WIN32_LEAN_AND_MEAN 20 # define WIN32_LEAN_AND_MEAN 21 # define EIGEN_BT_UNDEF_WIN32_LEAN_AND_MEAN 24 #elif defined(__APPLE__) 25 #include <CoreServices/CoreServices.h> 26 #include <mach/mach_time.h> 54 #if defined(_WIN32) || defined(__CYGWIN__) 56 QueryPerformanceFrequency(&freq);
57 m_frequency = (double)freq.QuadPart;
72 m_starts[CPU_TIMER] = getCpuTime();
73 m_starts[REAL_TIMER] = getRealTime();
77 m_times[CPU_TIMER] = getCpuTime() - m_starts[CPU_TIMER];
78 m_times[REAL_TIMER] = getRealTime() - m_starts[REAL_TIMER];
79 #if EIGEN_VERSION_AT_LEAST(2,90,0) 80 m_bests = m_bests.cwiseMin(m_times);
81 m_worsts = m_worsts.cwiseMax(m_times);
83 m_bests(0) = std::min(m_bests(0),m_times(0));
84 m_bests(1) = std::min(m_bests(1),m_times(1));
85 m_worsts(0) = std::max(m_worsts(0),m_times(0));
86 m_worsts(1) = std::max(m_worsts(1),m_times(1));
93 inline double value(
int TIMER = CPU_TIMER)
const 95 return m_times[TIMER];
100 inline double best(
int TIMER = CPU_TIMER)
const 102 return m_bests[TIMER];
107 inline double worst(
int TIMER = CPU_TIMER)
const 109 return m_worsts[TIMER];
114 inline double total(
int TIMER = CPU_TIMER)
const 116 return m_totals[TIMER];
119 inline double getCpuTime()
const 122 LARGE_INTEGER query_ticks;
123 QueryPerformanceCounter(&query_ticks);
124 return query_ticks.QuadPart/m_frequency;
126 return double(mach_absolute_time())*1e-9;
129 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
130 return double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
134 inline double getRealTime()
const 139 return (
double)st.wSecond + 1.e-3 * (double)st.wMilliseconds;
141 return double(mach_absolute_time())*1e-9;
144 clock_gettime(CLOCK_REALTIME, &ts);
145 return double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
150 #if defined(_WIN32) || defined(__CYGWIN__) 160 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
163 #define BENCH(TIMER,TRIES,REP,CODE) { \ 165 for(int uglyvarname1=0; uglyvarname1<TRIES; ++uglyvarname1){ \ 167 for(int uglyvarname2=0; uglyvarname2<REP; ++uglyvarname2){ \ 177 #ifdef EIGEN_BT_UNDEF_NOMINMAX 178 # undef EIGEN_BT_UNDEF_NOMINMAX 182 #ifdef EIGEN_BT_UNDEF_WIN32_LEAN_AND_MEAN 183 # undef EIGEN_BT_UNDEF_WIN32_LEAN_AND_MEAN 184 # undef WIN32_LEAN_AND_MEAN 187 #endif // EIGEN_BENCH_TIMERR_H double value(int TIMER=CPU_TIMER) const
Return the elapsed time in seconds between the last start/stop pair.
Definition: BenchTimer.h:93
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
Elapsed time timer keeping the best try.
Definition: BenchTimer.h:48
double best(int TIMER=CPU_TIMER) const
Return the best elapsed time in seconds.
Definition: BenchTimer.h:100
double total(int TIMER=CPU_TIMER) const
Return the total elapsed time in seconds.
Definition: BenchTimer.h:114
double worst(int TIMER=CPU_TIMER) const
Return the worst elapsed time in seconds.
Definition: BenchTimer.h:107