]> Creatis software - clitk.git/blobdiff - common/clitkTimer.cxx
mechanism for hiding experimental stuff in vv
[clitk.git] / common / clitkTimer.cxx
index 85b65fde02689c9725a4b75d8982c79a51a29bdb..ac4033e76c75bcc9de50eff12fe17701b9e9fd69 100644 (file)
 /// Constructs the class 
 clitk::Timer::Timer() { 
   Reset(); 
+#if defined(WIN32)
+  QueryPerformanceFrequency((LARGE_INTEGER*)&mFrequency);
+#endif
 }
 //====================================================================
 
 //====================================================================
 void clitk::Timer::Start() {
+#if defined(unix)
   getrusage(RUSAGE_SELF, &mBegin);
+#elif defined(WIN32)
+  QueryPerformanceCounter((LARGE_INTEGER*)&mBegin);
+#endif
   mNumberOfCall++;
 }
 //====================================================================
 
 //====================================================================
 void clitk::Timer::Stop(bool accumulate) {
+#if defined(unix)
   getrusage(RUSAGE_SELF, &mEnd);
   if (accumulate) {
     mElapsed += (mEnd.ru_utime.tv_usec - mBegin.ru_utime.tv_usec)+
       (mEnd.ru_utime.tv_sec - mBegin.ru_utime.tv_sec)*1000000;
   }
+#elif defined(WIN32)
+  QueryPerformanceCounter((LARGE_INTEGER*)&mEnd);
+  if (accumulate) {
+    mElapsed += ((mEnd-mBegin)*1000000)/(long double)mFrequency;
+  }
+#endif
   else {
     mNumberOfCall--;
   }