11 #ifndef INCLUDED_GNURADIO_HIGH_RES_TIMER_H
12 #define INCLUDED_GNURADIO_HIGH_RES_TIMER_H
21 #if defined(linux) || defined(__linux) || defined(__linux__)
22 #define GNURADIO_HRT_USE_CLOCK_GETTIME
24 #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
25 #define GNURADIO_HRT_USE_QUERY_PERFORMANCE_COUNTER
26 #elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
27 #define GNURADIO_HRT_USE_MACH_ABSOLUTE_TIME
28 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
29 #define GNURADIO_HRT_USE_CLOCK_GETTIME
32 #define GNURADIO_HRT_USE_GENERIC_CLOCK
54 #ifdef GNURADIO_HRT_USE_CLOCK_GETTIME
62 #ifdef GNURADIO_HRT_USE_CLOCK_GETTIME
66 clock_gettime(CLOCK_MONOTONIC, &ts);
73 clock_gettime(high_res_timer_source, &ts);
81 #ifdef GNURADIO_HRT_USE_MACH_ABSOLUTE_TIME
82 #include <mach/mach_time.h>
86 return mach_absolute_time();
96 mach_timebase_info_data_t info;
97 mach_timebase_info(&info);
103 #ifdef GNURADIO_HRT_USE_QUERY_PERFORMANCE_COUNTER
108 LARGE_INTEGER counts;
109 QueryPerformanceCounter(&counts);
110 return counts.QuadPart;
121 QueryPerformanceFrequency(&freq);
122 return freq.QuadPart;
127 #ifdef GNURADIO_HRT_USE_GENERIC_CLOCK
130 return std::chrono::duration<gr::high_res_timer_type, std::nano>(
131 std::chrono::steady_clock::now().time_since_epoch())
147 const double seconds_since_epoch =
148 std::chrono::duration<double>(std::chrono::system_clock::now().time_since_epoch())
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29
high_res_timer_type high_res_timer_now(void)
Get the current time in ticks.
Definition: high_res_timer.h:128
high_res_timer_type high_res_timer_tps(void)
Get the number of ticks per second.
Definition: high_res_timer.h:140
high_res_timer_type high_res_timer_now_perfmon(void)
Get the current time in ticks - for performance monitoring.
Definition: high_res_timer.h:135
high_res_timer_type high_res_timer_epoch(void)
Get the tick count at the epoch.
Definition: high_res_timer.h:144
signed long long high_res_timer_type
Typedef for the timer tick count.
Definition: high_res_timer.h:40