21 #ifndef __TBB_tick_count_H 22 #define __TBB_tick_count_H 24 #include "tbb_stddef.h" 27 #include "machine/windows_api.h" 43 explicit interval_t(
long long value_ ) : value(value_) {}
75 static long long ticks_per_second(){
78 int rval = QueryPerformanceFrequency(&qpfreq);
79 __TBB_ASSERT_EX(rval,
"QueryPerformanceFrequency returned zero");
80 return static_cast<long long>(qpfreq.QuadPart);
82 return static_cast<long long>(1E9);
84 return static_cast<long long>(1E6);
99 static double resolution() {
return 1.0 / interval_t::ticks_per_second(); }
109 int rval = QueryPerformanceCounter(&qpcnt);
110 __TBB_ASSERT_EX(rval,
"QueryPerformanceCounter failed");
111 result.my_count = qpcnt.QuadPart;
114 int status = clock_gettime( CLOCK_REALTIME, &ts );
115 __TBB_ASSERT_EX( status==0,
"CLOCK_REALTIME not supported" );
116 result.my_count =
static_cast<long long>(1000000000UL)*static_cast<long long>(ts.tv_sec) +
static_cast<long long>(ts.tv_nsec);
119 int status = gettimeofday(&tv, NULL);
120 __TBB_ASSERT_EX( status==0,
"gettimeofday failed" );
121 result.my_count =
static_cast<long long>(1000000)*static_cast<long long>(tv.tv_sec) +
static_cast<long long>(tv.tv_usec);
127 value =
static_cast<long long>(sec*interval_t::ticks_per_second());
static double resolution()
Return the resolution of the clock in seconds per tick.
Definition: tick_count.h:99
friend interval_t operator-(const interval_t &i, const interval_t &j)
Subtract two intervals.
Definition: tick_count.h:65
interval_t & operator+=(const interval_t &i)
Accumulation operator.
Definition: tick_count.h:70
Absolute timestamp.
Definition: tick_count.h:38
friend interval_t operator-(const tick_count &t1, const tick_count &t0)
Extract the intervals from the tick_counts and subtract them.
Definition: tick_count.h:130
friend interval_t operator+(const interval_t &i, const interval_t &j)
Add two intervals.
Definition: tick_count.h:60
tick_count()
Construct an absolute timestamp initialized to zero.
Definition: tick_count.h:90
interval_t & operator-=(const interval_t &i)
Subtraction operator.
Definition: tick_count.h:73
static tick_count now()
Return current time.
Definition: tick_count.h:105
interval_t()
Construct a time interval representing zero time duration.
Definition: tick_count.h:46
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44
Relative time interval.
Definition: tick_count.h:41
double seconds() const
Return the length of a time interval in seconds.
Definition: tick_count.h:134