tbb::tick_count Class Reference
Timing

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.

: my_count(0) {};

## Member Function Documentation

## now()

tick_count tbb::tick_count::now | ( |  | ) |

inline static

Return current time.

Definition at line 101 of file tick_count.h.

{
tick_count result;
#if _WIN32||_WIN64
LARGE_INTEGER qpcnt;
int rval = QueryPerformanceCounter(&qpcnt);
__TBB_ASSERT_EX(rval, "QueryPerformanceCounter failed");
result.my_count = qpcnt.QuadPart;
#elif __linux__
struct timespec ts;
int status = clock_gettime( CLOCK_REALTIME, &ts );
__TBB_ASSERT_EX( status==0, "CLOCK_REALTIME not supported" );
result.my_count = static_cast<long long>(1000000000UL)*static_cast<long long>(ts.tv_sec) + static_cast<long long>(ts.tv_nsec);
#else /* generic Unix */
struct timeval tv;
int status = gettimeofday(&tv, NULL);
__TBB_ASSERT_EX( status==0, "gettimeofday failed" );
result.my_count = static_cast<long long>(1000000)*static_cast<long long>(tv.tv_sec) + static_cast<long long>(tv.tv_usec);
#endif /*(choice of OS) */
return result;
}

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 | ( |  | ) |

inline static

Return the resolution of the clock in seconds per tick.

Definition at line 95 of file tick_count.h.

{ return 1.0 / interval_t::ticks_per_second(); }

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.

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

## 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:

- tick_count.h

tbb::tick_count::interval_t::ticks_per_second
static long long ticks_per_second()
Definition: tick_count.h:71
tbb::tick_count::tick_count
tick_count()
Construct an absolute timestamp initialized to zero.
Definition: tick_count.h:86
tbb::tick_count::my_count
long long my_count
Definition: tick_count.h:98
__TBB_ASSERT_EX
#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

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.