33 #ifndef SHARK_CORE_TIMER_H 34 #define SHARK_CORE_TIMER_H 38 #define WIN32_LEAN_AND_MEAN 42 #include <sys/resource.h> 59 Timer(
bool measureWallclockTime =
true)
62 , m_measureWallclockTime(measureWallclockTime)
66 static double now(
bool measureWallclockTime =
true) {
68 if(measureWallclockTime){
69 return static_cast<double>(std::clock()) / CLOCKS_PER_SEC;
72 LARGE_INTEGER tick, tps;
73 QueryPerformanceFrequency(&tps);
74 QueryPerformanceCounter(&tick);
75 return( static_cast<double>( tick.QuadPart ) / static_cast<double>( tps.QuadPart ) );
78 if(measureWallclockTime){
80 if (gettimeofday(&time,0)){
84 return time.tv_sec +1e-6 *time.tv_usec;
89 getrusage(RUSAGE_SELF, &res);
90 return(res.ru_utime.tv_sec + res.ru_stime.tv_sec)
91 + 1e-6 * (res.ru_utime.tv_usec + res.ru_stime.tv_usec);
98 m_startTime =
now(m_measureWallclockTime);
106 double stop =
now(m_measureWallclockTime);
107 m_lastLap = stop - m_startTime;
111 if ( m_lastLap < 0.0 ) {
126 bool m_measureWallclockTime;