HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Static Public Member Functions
tt::time_stamp_count Class Reference

#include <ttauri/time_stamp_count.hpp>

Data Structures

struct  inplace
 
struct  inplace_with_cpu_id
 
struct  inplace_with_thread_id
 

Public Member Functions

constexpr time_stamp_count (uint64_t count, uint32_t aux) noexcept
 
 time_stamp_count (time_stamp_count::inplace) noexcept
 Use a constructor to in-place create the timestamp.
 
 time_stamp_count (time_stamp_count::inplace_with_cpu_id) noexcept
 Use a constructor to in-place create the timestamp.
 
 time_stamp_count (time_stamp_count::inplace_with_thread_id) noexcept
 Use a constructor to in-place create the timestamp.
 
ssize_t cpu_id () const noexcept
 Get the logical CPU index.
 
constexpr uint32_t thread_id () const noexcept
 Get the thread id.
 
constexpr uint64_t count () const noexcept
 Get the count since epoch.
 
std::chrono::nanoseconds time_since_epoch () const noexcept
 Convert to nanoseconds since epoch.
 
constexpr time_stamp_countoperator+= (uint64_t rhs) noexcept
 
constexpr time_stamp_count operator+ (uint64_t rhs) const noexcept
 

Static Public Member Functions

static time_stamp_count now () noexcept
 Get the current count from the CPU's time stamp count.
 
static std::chrono::nanoseconds duration_from_count (uint64_t count) noexcept
 Convert a time-stamp count to a duration.
 
static uint64_t measure_frequency (std::chrono::milliseconds duration) noexcept
 Measure the frequency of the time_stamp_count.
 
static void set_frequency (uint64_t frequency) noexcept
 
static void start_subsystem () noexcept
 Start the time_stamp_count subsystem.
 

Detailed Description

Since Window's 10 QueryPerformanceCounter() counts at only 10MHz which is too low to measure performance in many cases.

Instead we will use the TSC.

Constructor & Destructor Documentation

◆ time_stamp_count() [1/3]

tt::time_stamp_count::time_stamp_count ( time_stamp_count::inplace )
inlineexplicitnoexcept

Use a constructor to in-place create the timestamp.

◆ time_stamp_count() [2/3]

tt::time_stamp_count::time_stamp_count ( time_stamp_count::inplace_with_cpu_id )
inlineexplicitnoexcept

Use a constructor to in-place create the timestamp.

◆ time_stamp_count() [3/3]

tt::time_stamp_count::time_stamp_count ( time_stamp_count::inplace_with_thread_id )
inlineexplicitnoexcept

Use a constructor to in-place create the timestamp.

Member Function Documentation

◆ count()

constexpr uint64_t tt::time_stamp_count::count ( ) const
inlineconstexprnoexcept

Get the count since epoch.

The epoch is the same as the TSC count's epoch. In most cases the epoch is at system startup time.

◆ cpu_id()

ssize_t tt::time_stamp_count::cpu_id ( ) const
inlinenoexcept

Get the logical CPU index.

This is logical CPU id that the operating system uses for things like thread affinity.

Returns
the processor index, or -1 if the processor index is unknown.

◆ duration_from_count()

static std::chrono::nanoseconds tt::time_stamp_count::duration_from_count ( uint64_t count)
inlinestaticnoexcept

Convert a time-stamp count to a duration.

Parameters
countThe number clock ticks.
Returns
A period of nanoseconds representing the count of clock ticks.

◆ measure_frequency()

static uint64_t tt::time_stamp_count::measure_frequency ( std::chrono::milliseconds duration)
staticnoexcept

Measure the frequency of the time_stamp_count.

Frequency drift from TSC is 1ppm

◆ now()

static time_stamp_count tt::time_stamp_count::now ( )
inlinestaticnoexcept

Get the current count from the CPU's time stamp count.

Returns
The current clock count and CPU-id.

◆ start_subsystem()

static void tt::time_stamp_count::start_subsystem ( )
staticnoexcept

Start the time_stamp_count subsystem.

◆ thread_id()

constexpr uint32_t tt::time_stamp_count::thread_id ( ) const
inlineconstexprnoexcept

Get the thread id.

Precondition
Must call time_stamp_count(time_stamp_count::inplace_with_thread_id) first.

◆ time_since_epoch()

std::chrono::nanoseconds tt::time_stamp_count::time_since_epoch ( ) const
inlinenoexcept

Convert to nanoseconds since epoch.

The epoch is the same as the TSC count's epoch. In most cases the epoch is at system startup time.


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