Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::tick_count Class Reference

Absolute timestamp. More...

#include <tick_count.h>

Collaboration diagram for tbb::tick_count:

Classes

class  interval_t
 Relative time interval. More...
 

Public Member Functions

 tick_count ()
 Construct an absolute timestamp initialized to zero. More...
 

Static Public Member Functions

static tick_count now ()
 Return current time. More...
 
static double resolution ()
 Return the resolution of the clock in seconds per tick. More...
 

Private Attributes

long long my_count
 

Friends

interval_t operator- (const tick_count &t1, const tick_count &t0)
 Subtract two timestamps to get the time interval between. More...
 

Detailed Description

Absolute timestamp.

Definition at line 34 of file tick_count.h.

Constructor & Destructor Documentation

◆ tick_count()

tbb::tick_count::tick_count ( )
inline

Construct an absolute timestamp initialized to zero.

Definition at line 86 of file tick_count.h.

86 : my_count(0) {};
long long my_count
Definition: tick_count.h:98

Member Function Documentation

◆ now()

tick_count tbb::tick_count::now ( )
inlinestatic

Return current time.

Definition at line 101 of file tick_count.h.

101  {
102  tick_count result;
103 #if _WIN32||_WIN64
104  LARGE_INTEGER qpcnt;
105  int rval = QueryPerformanceCounter(&qpcnt);
106  __TBB_ASSERT_EX(rval, "QueryPerformanceCounter failed");
107  result.my_count = qpcnt.QuadPart;
108 #elif __linux__
109  struct timespec ts;
110  int status = clock_gettime( CLOCK_REALTIME, &ts );
111  __TBB_ASSERT_EX( status==0, "CLOCK_REALTIME not supported" );
112  result.my_count = static_cast<long long>(1000000000UL)*static_cast<long long>(ts.tv_sec) + static_cast<long long>(ts.tv_nsec);
113 #else /* generic Unix */
114  struct timeval tv;
115  int status = gettimeofday(&tv, NULL);
116  __TBB_ASSERT_EX( status==0, "gettimeofday failed" );
117  result.my_count = static_cast<long long>(1000000)*static_cast<long long>(tv.tv_sec) + static_cast<long long>(tv.tv_usec);
118 #endif /*(choice of OS) */
119  return result;
120 }
#define __TBB_ASSERT_EX(predicate, comment)
"Extended" version is useful to suppress warnings if a variable is only used with an assert
Definition: tbb_stddef.h:167
tick_count()
Construct an absolute timestamp initialized to zero.
Definition: tick_count.h:86

References __TBB_ASSERT_EX, and my_count.

Referenced by tbb::internal::thread_sleep_v3().

Here is the caller graph for this function:

◆ resolution()

static double tbb::tick_count::resolution ( )
inlinestatic

Return the resolution of the clock in seconds per tick.

Definition at line 95 of file tick_count.h.

95 { return 1.0 / interval_t::ticks_per_second(); }
static long long ticks_per_second()
Definition: tick_count.h:71

References tbb::tick_count::interval_t::ticks_per_second().

Referenced by tbb::tick_count::interval_t::seconds().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator-

interval_t operator- ( const tick_count t1,
const tick_count t0 
)
friend

Subtract two timestamps to get the time interval between.

Definition at line 126 of file tick_count.h.

126  {
127  return tick_count::interval_t( t1.my_count-t0.my_count );
128 }

Member Data Documentation

◆ my_count

long long tbb::tick_count::my_count
private

Definition at line 98 of file tick_count.h.

Referenced by now(), and tbb::operator-().


The documentation for this class was generated from the following file:

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.