17 #if defined(_WIN32) || defined(_WIN64)
24 static LARGE_INTEGER frequency = []() {
26 QueryPerformanceFrequency(&f);
30 LARGE_INTEGER counter;
32 QueryPerformanceCounter(&counter);
36 static_cast<int64_t>((
static_cast<long double>(counter.QuadPart) * 1000000000.0L) /
37 static_cast<long double>(frequency.QuadPart));
42 #elif defined(__linux__) || defined(__unix__) || defined(_POSIX_VERSION)
46 static inline timepoint_t high_res_now()
53 clock_gettime(CLOCK_MONOTONIC, &ts);
55 tp.nanoseconds =
static_cast<int64_t>(ts.tv_sec * 1000000000LL + ts.tv_nsec);
64 static inline timepoint_t high_res_now()
67 time_t t = time(NULL);
68 tp.nanoseconds =
static_cast<int64_t>(t * 1000000000LL);
75 static inline int64_t duration_ns(timepoint_t start, timepoint_t end)
77 return end.nanoseconds - start.nanoseconds;
80 static inline int64_t duration_us(timepoint_t start, timepoint_t end)
82 return (end.nanoseconds - start.nanoseconds) / 1000LL;
85 static inline int64_t duration_ms(timepoint_t start, timepoint_t end)
87 return (end.nanoseconds - start.nanoseconds) / 1000000LL;
90 static inline double duration_sec(timepoint_t start, timepoint_t end)
92 return static_cast<double>(end.nanoseconds - start.nanoseconds) / 1000000000.0;
Definition: cluster_descriptor.hpp:13
signed __int64 int64_t
Definition: stdint.h:135
Definition: high_res_cpu_clock.hpp:12
int64_t nanoseconds
Definition: high_res_cpu_clock.hpp:13