carb::time::tsc_clock
Defined in carb/time/TscClock.h
-
class tsc_clock
Static class for a CPU time-stamp clock.
The functions and types within this class are used for sampling the CPU’s time-stamp counter—typically a clock- cycle resolution clock directly within the CPU hardware.
Public Types
Public Static Functions
-
static inline Sample sample() noexcept
Read a sample from the CPU time-stamp clock.
Note that this operation is intended to be as fast as possible to maintain accuracy.
- Returns
a time-stamp Sample at the time the function is called.
-
static inline Freq frequency() noexcept
Computes the frequency of the CPU time-stamp clock.
The first call to this function can take longer as the CPU time-stamp clock is calibrated.
Note
This implementation assumes that the frequency never changes. Please verify with your CPU architecture that this assumption is correct.
- Returns
the computed Freq of the CPU time-stamp clock.
-
template<class Duration>
static inline Duration duration(Sample older, Sample newer) noexcept Computes the difference of two samples as a std::chrono::duration.
- Template Parameters
Duration – a
std::chrono::duration
template to convert to.- Parameters
older – The older (starting) sample
newer – The newer (ending) sample
- Returns
The difference in timestamps as the requested
Duration
representation
-
static inline Sample sample() noexcept