22 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
26 #define USE_QUERY_PERFORMANCE_COUNTER
28 #elif defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
32 #define USE_CLOCK_GETTIME
36 #elif defined(__APPLE__) || defined(__MACH__)
37 #include <TargetConditionals.h>
39 #include <Availability.h>
40 #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
41 #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
45 #define USE_CLOCK_GETTIME
48 #if !defined(CLOCK_REALTIME)
49 #define CLOCK_REALTIME 0
92 uint64_t time_stamp = 0;
94 #if defined(USE_CLOCK_GETTIME)
97 struct timespec clock;
98 if (clock_gettime(CLOCK_REALTIME, &clock) == -1)
105 time_stamp = clock.tv_sec * 1e9 + clock.tv_nsec;
107 #elif defined(USE_QUERY_PERFORMANCE_COUNTER)
111 if (!QueryPerformanceCounter(&ticks))
117 time_stamp =
static_cast<uint64_t
>(ticks.QuadPart);
128 time_stamp =
static_cast<uint64_t
>(std::time(0)) +
129 static_cast<uint64_t
>(std::clock());
uint64_t get_highres_time_stamp(void)