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 <mach/mach_time.h>
31 #if EIGEN_COMP_GNUC || EIGEN_COMP_CLANG
32 asm volatile(
"" : :
"g"(
p) :
"memory");
37 #if EIGEN_COMP_GNUC || EIGEN_COMP_CLANG
38 asm volatile(
"" : : :
"memory");
65 #if defined(_WIN32) || defined(__CYGWIN__)
67 QueryPerformanceFrequency(&freq);
68 m_frequency = (double)freq.QuadPart;
90 #if EIGEN_VERSION_AT_LEAST(2,90,0)
133 LARGE_INTEGER query_ticks;
134 QueryPerformanceCounter(&query_ticks);
135 return query_ticks.QuadPart/m_frequency;
137 return double(mach_absolute_time())*1
e-9;
140 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
141 return double(ts.tv_sec) + 1
e-9 * double(ts.tv_nsec);
150 return (
double)st.wSecond + 1.e-3 * (double)st.wMilliseconds;
152 return double(mach_absolute_time())*1
e-9;
155 clock_gettime(CLOCK_REALTIME, &ts);
156 return double(ts.tv_sec) + 1
e-9 * double(ts.tv_nsec);
161 #if defined(_WIN32) || defined(__CYGWIN__)
174 #define BENCH(TIMER,TRIES,REP,CODE) { \
176 for(int uglyvarname1=0; uglyvarname1<TRIES; ++uglyvarname1){ \
178 for(int uglyvarname2=0; uglyvarname2<REP; ++uglyvarname2){ \
189 #ifdef EIGEN_BT_UNDEF_NOMINMAX
190 # undef EIGEN_BT_UNDEF_NOMINMAX
194 #ifdef EIGEN_BT_UNDEF_WIN32_LEAN_AND_MEAN
195 # undef EIGEN_BT_UNDEF_WIN32_LEAN_AND_MEAN
196 # undef WIN32_LEAN_AND_MEAN
199 #endif // EIGEN_BENCH_TIMERR_H