Ocean
Ocean::HighPerformanceTimer Class Reference

This class implements a high performance timer. More...

Public Types

typedef int64_t Ticks
 Definition of CPU ticks. More...
 

Public Member Functions

 HighPerformanceTimer ()
 Creates a new timer and starts the time measurement. More...
 
void start ()
 (Re-)starts the time measurement. More...
 
double seconds () const
 Returns the measured time since the timer has been started in seconds. More...
 
double mseconds () const
 Returns the measured time since the timer has been started in milliseconds. More...
 
double yseconds () const
 Returns the measured time since the timer has been started in microseconds. More...
 
double nseconds () const
 Returns the measured time since the timer has been started in nanoseconds. More...
 

Static Public Member Functions

static Ticks precision ()
 Returns the precision of the timer. More...
 
static Ticks ticks ()
 Returns the recent CPU ticks. More...
 
static double ticks2seconds (const Ticks ticks)
 Converts a given CPU tick into seconds regarding the resolution of the timer. More...
 

Static Protected Member Functions

static Ticks ticksPerSecond ()
 Returns the resolution of the timer in ticks per second. More...
 

Protected Attributes

Ticks ticksStart_ = Ticks(0)
 The number of CPU ticks when starting the timer. More...
 

Detailed Description

This class implements a high performance timer.

Use this timer to measure time durations with high accuracy.
The measurement can be very helpful to detect performance bottlenecks.
Use the HighPerformanceTimer::precision() to retrieve the possible accuracy of this high performance timer.
The implementation is platform dependent.

Member Typedef Documentation

◆ Ticks

Definition of CPU ticks.

Constructor & Destructor Documentation

◆ HighPerformanceTimer()

Ocean::HighPerformanceTimer::HighPerformanceTimer ( )

Creates a new timer and starts the time measurement.

Member Function Documentation

◆ mseconds()

double Ocean::HighPerformanceTimer::mseconds ( ) const

Returns the measured time since the timer has been started in milliseconds.

Returns
Measured milliseconds

◆ nseconds()

double Ocean::HighPerformanceTimer::nseconds ( ) const

Returns the measured time since the timer has been started in nanoseconds.

Returns
Measured nanoseconds

◆ precision()

static Ticks Ocean::HighPerformanceTimer::precision ( )
static

Returns the precision of the timer.

Returns
Countable ticks per seconds

◆ seconds()

double Ocean::HighPerformanceTimer::seconds ( ) const

Returns the measured time since the timer has been started in seconds.

Returns
Measured seconds

◆ start()

void Ocean::HighPerformanceTimer::start ( )
inline

(Re-)starts the time measurement.

◆ ticks()

static Ticks Ocean::HighPerformanceTimer::ticks ( )
static

Returns the recent CPU ticks.

Returns
Recent CPU ticks

◆ ticks2seconds()

double Ocean::HighPerformanceTimer::ticks2seconds ( const Ticks  ticks)
inlinestatic

Converts a given CPU tick into seconds regarding the resolution of the timer.

Parameters
ticksThe ticks to convert
Returns
The Number of seconds matching with the given CPU ticks

◆ ticksPerSecond()

static Ticks Ocean::HighPerformanceTimer::ticksPerSecond ( )
staticprotected

Returns the resolution of the timer in ticks per second.

Returns
Ticks per second

◆ yseconds()

double Ocean::HighPerformanceTimer::yseconds ( ) const

Returns the measured time since the timer has been started in microseconds.

Returns
Measured microseconds

Field Documentation

◆ ticksStart_

Ticks Ocean::HighPerformanceTimer::ticksStart_ = Ticks(0)
protected

The number of CPU ticks when starting the timer.


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