X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkTimer.cxx;h=ac4033e76c75bcc9de50eff12fe17701b9e9fd69;hb=ea61e98aed4316bda8b156aea5980b08eaf4302b;hp=85b65fde02689c9725a4b75d8982c79a51a29bdb;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/common/clitkTimer.cxx b/common/clitkTimer.cxx index 85b65fd..ac4033e 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--; }