11 #ifndef INCLUDED_GNURADIO_HIGH_RES_TIMER_H
12 #define INCLUDED_GNURADIO_HIGH_RES_TIMER_H
19 #if defined(linux) || defined(__linux) || defined(__linux__)
20 #define GNURADIO_HRT_USE_CLOCK_GETTIME
22 #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
23 #define GNURADIO_HRT_USE_QUERY_PERFORMANCE_COUNTER
24 #elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
25 #define GNURADIO_HRT_USE_MACH_ABSOLUTE_TIME
26 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
27 #define GNURADIO_HRT_USE_CLOCK_GETTIME
30 #define GNURADIO_HRT_USE_MICROSEC_CLOCK
52 #ifdef GNURADIO_HRT_USE_CLOCK_GETTIME
60 #ifdef GNURADIO_HRT_USE_CLOCK_GETTIME
64 clock_gettime(CLOCK_MONOTONIC, &ts);
71 clock_gettime(high_res_timer_source, &ts);
79 #ifdef GNURADIO_HRT_USE_MACH_ABSOLUTE_TIME
80 #include <mach/mach_time.h>
84 return mach_absolute_time();
94 mach_timebase_info_data_t info;
95 mach_timebase_info(&info);
101 #ifdef GNURADIO_HRT_USE_QUERY_PERFORMANCE_COUNTER
106 LARGE_INTEGER counts;
107 QueryPerformanceCounter(&counts);
108 return counts.QuadPart;
119 QueryPerformanceFrequency(&freq);
120 return freq.QuadPart;
125 #ifdef GNURADIO_HRT_USE_MICROSEC_CLOCK
126 #include <boost/date_time/posix_time/posix_time.hpp>
130 static const boost::posix_time::ptime epoch(boost::posix_time::from_time_t(0));
131 return (boost::posix_time::microsec_clock::universal_time() - epoch).ticks();
141 return boost::posix_time::time_duration::ticks_per_second();
146 #include <boost/date_time/posix_time/posix_time.hpp>
150 static const double hrt_ticks_per_utc_ticks =
152 double(boost::posix_time::time_duration::ticks_per_second());
153 boost::posix_time::time_duration utc =
154 boost::posix_time::microsec_clock::universal_time() -
155 boost::posix_time::from_time_t(0);
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:18
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
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:139
high_res_timer_type high_res_timer_now_perfmon(void)
Get the current time in ticks - for performance monitoring.
Definition: high_res_timer.h:134
high_res_timer_type high_res_timer_epoch(void)
Get the tick count at the epoch.
Definition: high_res_timer.h:148
signed long long high_res_timer_type
Typedef for the timer tick count.
Definition: high_res_timer.h:38