AGX Dynamics  2.37.3.2
agx::HighAccuracyTimer Class Reference

The HighAccurayTimer class can replace the regular Timer class in high level applications where the need for accuracy is greater than performance. More...

#include <HighAccuracyTimer.h>

Public Member Functions

 HighAccuracyTimer (bool startImmediately=false)
 Creates a HighAccuracyTimer. More...
 
UInt64 getNumTicks () const
 Report execution time in CPU cycles. More...
 
UInt64 getStartTick () const
 Return the start tick. More...
 
Real64 getTime () const
 Report total elapsed time since start in milliseconds, excluding intervals when the timer was suspended. More...
 
bool isRunning () const
 Return true if running. More...
 
void reset (bool startAfterReset=false)
 Clear all data. More...
 
void start ()
 Starts the HighAccuracyTimer. More...
 
void stop ()
 Stops the HighAccuracyTimer. More...
 

Static Public Member Functions

static Real64 convertToMs (UInt64 ticks)
 Return the given number of ticks in ms. More...
 
static UInt64 getCurrentTick ()
 Return raw value of the TSC register (in Windows: QueryPerformanceTimer). More...
 
static void initClockSpeed ()
 For internal use only. More...
 

Detailed Description

The HighAccurayTimer class can replace the regular Timer class in high level applications where the need for accuracy is greater than performance.

This timer should ONLY be used with low calling frequency, such as when measuring total computation time, where the regular timer accuracy can fall short on certain platforms (Windows).

As of now, this HighAccuracyTimer has identical accuracy and performance for MAC and Linux as the regular Timer class. (For Windows, QueryPerformanceFrequency/QueryPerformanceTimer is used).

Definition at line 63 of file HighAccuracyTimer.h.

Constructor & Destructor Documentation

◆ HighAccuracyTimer()

agx::HighAccuracyTimer::HighAccuracyTimer ( bool  startImmediately = false)
inline

Creates a HighAccuracyTimer.

Parameters
startImmediatelyShould the HighAccuracyTimer start immediately or start in stopped mode (now, but also after consequent calls to reset())?

Definition at line 140 of file HighAccuracyTimer.h.

Member Function Documentation

◆ convertToMs()

Real64 agx::HighAccuracyTimer::convertToMs ( UInt64  ticks)
static

Return the given number of ticks in ms.

Definition at line 288 of file HighAccuracyTimer.h.

◆ getCurrentTick()

UInt64 agx::HighAccuracyTimer::getCurrentTick ( )
static

Return raw value of the TSC register (in Windows: QueryPerformanceTimer).

Definition at line 240 of file HighAccuracyTimer.h.

References agxAbort1.

◆ getNumTicks()

UInt64 agx::HighAccuracyTimer::getNumTicks ( ) const

Report execution time in CPU cycles.

Definition at line 191 of file HighAccuracyTimer.h.

◆ getStartTick()

UInt64 agx::HighAccuracyTimer::getStartTick ( ) const

Return the start tick.

Definition at line 197 of file HighAccuracyTimer.h.

◆ getTime()

Real64 agx::HighAccuracyTimer::getTime ( ) const

Report total elapsed time since start in milliseconds, excluding intervals when the timer was suspended.

Definition at line 209 of file HighAccuracyTimer.h.

References AGX_FORCE_INLINE, and agxAssert1.

◆ initClockSpeed()

static void agx::HighAccuracyTimer::initClockSpeed ( )
static

For internal use only.

◆ isRunning()

bool agx::HighAccuracyTimer::isRunning ( ) const

Return true if running.

Definition at line 203 of file HighAccuracyTimer.h.

◆ reset()

void agx::HighAccuracyTimer::reset ( bool  startAfterReset = false)

Clear all data.

Definition at line 180 of file HighAccuracyTimer.h.

◆ start()

void agx::HighAccuracyTimer::start ( )

Starts the HighAccuracyTimer.

Calling start on a already started HighAccuracyTimer will have no effect.

Definition at line 148 of file HighAccuracyTimer.h.

◆ stop()

void agx::HighAccuracyTimer::stop ( )

Stops the HighAccuracyTimer.

Calling stop on a already stopped HighAccuracyTimer will have no effect. Upon stopping, the amount of cycles and time ran will be updated.

Definition at line 163 of file HighAccuracyTimer.h.


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