diff options
author | Tor Lillqvist <tml@collabora.com> | 2013-11-20 20:45:05 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2013-11-20 21:00:02 +0200 |
commit | 43da86747ada05c7a019ef0e5a54dc1e6a3e32b3 (patch) | |
tree | 63f251c489b031abd3dc07c97da34c648a5756d3 /sc | |
parent | fdo#71436 add Excel 2010 functions for F-distribution (diff) | |
download | core-43da86747ada05c7a019ef0e5a54dc1e6a3e32b3.tar.gz core-43da86747ada05c7a019ef0e5a54dc1e6a3e32b3.zip |
Simplify "timer" code and add OS X implementation
Change-Id: Id728dc3b422c76fcb6c0a1185caae6f05b9ca245
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/opencl_device.cxx | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/sc/source/core/opencl/opencl_device.cxx b/sc/source/core/opencl/opencl_device.cxx index ed0d2cc75064..cc9be18af9c7 100644 --- a/sc/source/core/opencl/opencl_device.cxx +++ b/sc/source/core/opencl/opencl_device.cxx @@ -9,6 +9,8 @@ #ifdef _WIN32 #include <windows.h> +#elif defined __MACH__ +#include <mach/mach_time.h> #else #include <sys/time.h> #endif @@ -62,9 +64,9 @@ struct LibreOfficeDeviceEvaluationIO struct timer { #ifdef _WIN32 - LARGE_INTEGER start, stop, frequency; + LARGE_INTEGER start; #else - long long start, stop, frequency; + long long start; #endif }; @@ -133,6 +135,8 @@ void timerStart(timer* mytimer) { #ifdef _WIN32 QueryPerformanceCounter(&mytimer->start); +#elif defined __MACH__ + mytimer->start = mach_absolute_time(); #else struct timespec s; clock_gettime(CLOCK_MONOTONIC, &s); @@ -144,15 +148,22 @@ void timerStart(timer* mytimer) double timerStop(timer* mytimer) { #ifdef _WIN32 - QueryPerformanceCounter(&mytimer->stop); - QueryPerformanceFrequency(&mytimer->frequency); - double time = ((double)(mytimer->stop.QuadPart - mytimer->start.QuadPart) / mytimer->frequency.QuadPart); + LARGE_INTEGER stop, frequency; + QueryPerformanceCounter(&stop); + QueryPerformanceFrequency(&frequency); + double time = ((double)(stop.QuadPart - mytimer->start.QuadPart) / frequency.QuadPart); +#elif defined __MACH__ + static mach_timebase_info_data_t info = { 0, 0 }; + if (info.numer == 0) + mach_timebase_info(&info); + long long stop = mach_absolute_time(); + double time = ((stop - mytimer->start) * (double) info.numer / info.denom) / 1000.0; #else struct timespec s; + long long stop; clock_gettime(CLOCK_MONOTONIC, &s); - mytimer->stop = (long long)s.tv_sec * (long long)1.0E6 + (long long)s.tv_nsec / (long long)1.0E3; - mytimer->frequency = (long long)1.0E6; - double time = ((double)(mytimer->stop - mytimer->start) / mytimer->frequency); + stop = (long long)s.tv_sec * (long long)1.0E6 + (long long)s.tv_nsec / (long long)1.0E3; + double time = ((double)(stop - mytimer->start) / 1.0E6); #endif return time; } |