22 #ifndef INCLUDED_GNURADIO_HIGH_RES_TIMER_H
23 #define INCLUDED_GNURADIO_HIGH_RES_TIMER_H
30 #if defined(linux) || defined(__linux) || defined(__linux__)
31 #define GNURADIO_HRT_USE_CLOCK_GETTIME
33 #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
34 #define GNURADIO_HRT_USE_QUERY_PERFORMANCE_COUNTER
35 #elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
36 #define GNURADIO_HRT_USE_MACH_ABSOLUTE_TIME
37 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
38 #define GNURADIO_HRT_USE_CLOCK_GETTIME
41 #define GNURADIO_HRT_USE_MICROSEC_CLOCK
63 #ifdef GNURADIO_HRT_USE_CLOCK_GETTIME
71 #ifdef GNURADIO_HRT_USE_CLOCK_GETTIME
74 clock_gettime(CLOCK_MONOTONIC, &ts);
80 clock_gettime(high_res_timer_source, &ts);
90 #ifdef GNURADIO_HRT_USE_MACH_ABSOLUTE_TIME
91 #include <mach/mach_time.h>
94 return mach_absolute_time();
102 mach_timebase_info_data_t info;
103 mach_timebase_info(&info);
109 #ifdef GNURADIO_HRT_USE_QUERY_PERFORMANCE_COUNTER
113 LARGE_INTEGER counts;
114 QueryPerformanceCounter(&counts);
115 return counts.QuadPart;
124 QueryPerformanceFrequency(&freq);
125 return freq.QuadPart;
130 #ifdef GNURADIO_HRT_USE_MICROSEC_CLOCK
131 #include <boost/date_time/posix_time/posix_time.hpp>
134 static const boost::posix_time::ptime epoch(boost::posix_time::from_time_t(0));
135 return (boost::posix_time::microsec_clock::universal_time() - epoch).ticks();
143 return boost::posix_time::time_duration::ticks_per_second();
148 #include <boost/date_time/posix_time/posix_time.hpp>
151 static const double hrt_ticks_per_utc_ticks =
gr::high_res_timer_tps()/double(boost::posix_time::time_duration::ticks_per_second());
152 boost::posix_time::time_duration utc = boost::posix_time::microsec_clock::universal_time() - boost::posix_time::from_time_t(0);
high_res_timer_type high_res_timer_now(void)
Get the current time in ticks.
Definition: high_res_timer.h:133
high_res_timer_type high_res_timer_epoch(void)
Get the tick count at the epoch.
Definition: high_res_timer.h:150
high_res_timer_type high_res_timer_tps(void)
Get the number of ticks per second.
Definition: high_res_timer.h:142
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
signed long long high_res_timer_type
Typedef for the timer tick count.
Definition: high_res_timer.h:49
high_res_timer_type high_res_timer_now_perfmon(void)
Get the current time in ticks - for performance monitoring.
Definition: high_res_timer.h:138