X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkTimer.cxx;h=6f39dc0e7ee335769bcea697c681fc130685baed;hb=4a567a442ac0d844a894e5de071d51a505d07f4a;hp=85b65fde02689c9725a4b75d8982c79a51a29bdb;hpb=26bbfd8756d07eb73acbfe2fcfd77b3a4f3b52a9;p=clitk.git diff --git a/common/clitkTimer.cxx b/common/clitkTimer.cxx index 85b65fd..6f39dc0 100644 --- a/common/clitkTimer.cxx +++ b/common/clitkTimer.cxx @@ -20,23 +20,37 @@ /// 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--; }