diff options
| author | lbavoil <[email protected]> | 2016-03-25 13:01:54 +0100 |
|---|---|---|
| committer | lbavoil <[email protected]> | 2016-03-25 13:01:54 +0100 |
| commit | 99174e4e5fb4b7079da80b35a6dfd68f3fd56a1c (patch) | |
| tree | fbcd4260d6c953d569a887505336a1c3f202e10f /build/tools/HLSLcc/May_2014/offline/timer.cpp | |
| download | hbaoplus-99174e4e5fb4b7079da80b35a6dfd68f3fd56a1c.tar.xz hbaoplus-99174e4e5fb4b7079da80b35a6dfd68f3fd56a1c.zip | |
GFSDK_HBAO+_distro_r3.0_cl20573789
Diffstat (limited to 'build/tools/HLSLcc/May_2014/offline/timer.cpp')
| -rw-r--r-- | build/tools/HLSLcc/May_2014/offline/timer.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/build/tools/HLSLcc/May_2014/offline/timer.cpp b/build/tools/HLSLcc/May_2014/offline/timer.cpp new file mode 100644 index 0000000..ac7858b --- /dev/null +++ b/build/tools/HLSLcc/May_2014/offline/timer.cpp @@ -0,0 +1,37 @@ +#include "timer.h" + +void InitTimer(Timer_t* psTimer) +{ +#if defined(_WIN32) + QueryPerformanceFrequency(&psTimer->frequency); +#endif +} + +void ResetTimer(Timer_t* psTimer) +{ +#if defined(_WIN32) + QueryPerformanceCounter(&psTimer->startCount); +#else + gettimeofday(&psTimer->startCount, 0); +#endif +} + +/* Returns time in micro seconds */ +double ReadTimer(Timer_t* psTimer) +{ + double startTimeInMicroSec, endTimeInMicroSec; + +#if defined(_WIN32) + const double freq = (1000000.0 / psTimer->frequency.QuadPart); + QueryPerformanceCounter(&psTimer->endCount); + startTimeInMicroSec = psTimer->startCount.QuadPart * freq; + endTimeInMicroSec = psTimer->endCount.QuadPart * freq; +#else + gettimeofday(&psTimer->endCount, 0); + startTimeInMicroSec = (psTimer->startCount.tv_sec * 1000000.0) + psTimer->startCount.tv_usec; + endTimeInMicroSec = (psTimer->endCount.tv_sec * 1000000.0) + psTimer->endCount.tv_usec; +#endif + + return endTimeInMicroSec - startTimeInMicroSec; +} + |