2 #ifndef CNOID_UTIL_TIME_MEASURE_H
3 #define CNOID_UTIL_TIME_MEASURE_H
9 #if _POSIX_C_SOURCE >= 199309L
35 clock_gettime(CLOCK_MONOTONIC, &tp) ;
43 double beginTime = tp.tv_sec + (double)tp.tv_nsec * 1.0e-9;
44 clock_gettime(CLOCK_MONOTONIC, &tp);
45 double endTime = tp.tv_sec + (double)tp.tv_nsec * 1.0e-9;
47 double beginTime = tv.tv_sec + (
double)tv.tv_usec * 1.0e-6;
49 double endTime = tv.tv_sec + (double)tv.tv_usec * 1.0e-6;
51 time_ = endTime - beginTime;
61 inline double time() {
return time_; }
73 typedef unsigned __int64 ulonglong;
77 ulonglong iTimerScale;
88 BOOL iDummyBool = QueryPerformanceFrequency ((LARGE_INTEGER *) &iTimerScale);
94 BOOL iDummyBool = QueryPerformanceCounter ((LARGE_INTEGER *) &beginTime);
100 BOOL iDummyBool = QueryPerformanceCounter ((LARGE_INTEGER *) &endTime);
103 time_ = (double)(endTime - beginTime) / iTimerScale;
111 inline double time() {
return time_; }
112 inline double totalTime() {
return totalTime_; }
113 inline double avarageTime() {
return totalTime_ / numCalls; }