TrueReality  v0.1.1912
trUtil::Timer Class Reference

Timer class is used for measuring elapsed time or time between two points. More...

#include <Timer.h>

Public Member Functions

 Timer ()
 Default constructor. More...
 
 ~Timer ()
 Destructor. More...
 
TimeTicks Tick ()
 Get the timers tick value. More...
 
void SetStartTick ()
 Set the start tick. More...
 
void SetStartTick (TimeTicks t)
 Set the start tick to a custom value. More...
 
TimeTicks GetStartTick () const
 Get the value of the start tick. More...
 
double DeltaSec (TimeTicks t1, TimeTicks t2) const
 Get the time in seconds between timer ticks t1 and t2. More...
 
double DeltaMil (TimeTicks t1, TimeTicks t2) const
 Get the time in milliseconds between timer ticks t1 and t2. More...
 
double DeltaMicro (TimeTicks t1, TimeTicks t2) const
 Get the time in microseconds between timer ticks t1 and t2. More...
 
double DeltaNano (TimeTicks t1, TimeTicks t2) const
 Get the time in nanoseconds between timer ticks t1 and t2. More...
 
double ElapsedSeconds () const
 Get elapsed time in seconds. More...
 
double ElapsedMilliseconds () const
 Get elapsed time in milliseconds. More...
 
double ElapsedMicroseconds () const
 Get elapsed time in microseconds. More...
 
double ElapsedNanoseconds () const
 Get elapsed time in nanoseconds. More...
 
double GetSecondsPerCPUTick () const
 Get the number of seconds per CPU tick. More...
 
double GetSecondsPerTick () const
 Get the number of seconds per tick. More...
 

Static Public Member Functions

static const TimerInstance ()
 Creates and returns a global timer. More...
 

Private Attributes

osg::Timer mTimer
 
TimeTicks mOldTicks = 0
 
TimeTicks mNewTicks = 0
 
TimeTicks mCustomTicks = 0
 

Detailed Description

Timer class is used for measuring elapsed time or time between two points.

Author
Maxim Serebrennik

Definition at line 65 of file Timer.h.

Constructor & Destructor Documentation

◆ Timer()

trUtil::Timer::Timer ( )

Default constructor.

Definition at line 45 of file Timer.cpp.

◆ ~Timer()

trUtil::Timer::~Timer ( )

Destructor.

Definition at line 51 of file Timer.cpp.

Member Function Documentation

◆ DeltaMicro()

double trUtil::Timer::DeltaMicro ( TimeTicks  t1,
TimeTicks  t2 
) const
inline

Get the time in microseconds between timer ticks t1 and t2.

Parameters
t1The first TimeTicks.
t2The second TimeTicks.
Returns
A double.

Definition at line 166 of file Timer.h.

◆ DeltaMil()

double trUtil::Timer::DeltaMil ( TimeTicks  t1,
TimeTicks  t2 
) const
inline

Get the time in milliseconds between timer ticks t1 and t2.

Parameters
t1The first TimeTicks.
t2The second TimeTicks.
Returns
A double.

Definition at line 154 of file Timer.h.

◆ DeltaNano()

double trUtil::Timer::DeltaNano ( TimeTicks  t1,
TimeTicks  t2 
) const
inline

Get the time in nanoseconds between timer ticks t1 and t2.

Parameters
t1The first TimeTicks.
t2The second TimeTicks.
Returns
A double.

Definition at line 178 of file Timer.h.

◆ DeltaSec()

double trUtil::Timer::DeltaSec ( TimeTicks  t1,
TimeTicks  t2 
) const
inline

Get the time in seconds between timer ticks t1 and t2.

Parameters
t1The first TimeTicks.
t2The second TimeTicks.
Returns
A double.

Definition at line 142 of file Timer.h.

◆ ElapsedMicroseconds()

double trUtil::Timer::ElapsedMicroseconds ( ) const
inline

Get elapsed time in microseconds.

Returns
A double.

Definition at line 205 of file Timer.h.

◆ ElapsedMilliseconds()

double trUtil::Timer::ElapsedMilliseconds ( ) const
inline

Get elapsed time in milliseconds.

Returns
A double.

Definition at line 196 of file Timer.h.

◆ ElapsedNanoseconds()

double trUtil::Timer::ElapsedNanoseconds ( ) const
inline

Get elapsed time in nanoseconds.

Returns
A double.

Definition at line 214 of file Timer.h.

◆ ElapsedSeconds()

double trUtil::Timer::ElapsedSeconds ( ) const
inline

Get elapsed time in seconds.

Returns
A double.

Definition at line 187 of file Timer.h.

◆ GetSecondsPerCPUTick()

double trUtil::Timer::GetSecondsPerCPUTick ( ) const
inline

Get the number of seconds per CPU tick.

Returns
The seconds per CPU tick.

Definition at line 223 of file Timer.h.

◆ GetSecondsPerTick()

double trUtil::Timer::GetSecondsPerTick ( ) const
inline

Get the number of seconds per tick.

Returns
The seconds per tick.

Definition at line 232 of file Timer.h.

Referenced by trCore::SceneObjects::RingArrayCallback::operator()(), trCore::SystemDirector::Run(), and trCore::SystemDirector::RunOnce().

Here is the caller graph for this function:

◆ GetStartTick()

TimeTicks trUtil::Timer::GetStartTick ( ) const
inline

Get the value of the start tick.

Returns
The start tick.

Definition at line 130 of file Timer.h.

◆ Instance()

const Timer * trUtil::Timer::Instance ( )
static

Creates and returns a global timer.

This allows the user to use the timer class as a singleton. It can still be declared locally though, without the use of Instance()

Returns
Null if it fails, else a pointer to a const Timer.

Definition at line 57 of file Timer.cpp.

◆ SetStartTick() [1/2]

void trUtil::Timer::SetStartTick ( )
inline

Set the start tick.

Definition at line 112 of file Timer.h.

Referenced by trCore::SceneObjects::RingArrayCallback::operator()(), trCore::SystemDirector::Run(), and trCore::SystemDirector::RunOnce().

Here is the caller graph for this function:

◆ SetStartTick() [2/2]

void trUtil::Timer::SetStartTick ( TimeTicks  t)

Set the start tick to a custom value.

Parameters
tThe TimeTicks to process.

Definition at line 64 of file Timer.cpp.

References mCustomTicks, mNewTicks, mOldTicks, and mTimer.

◆ Tick()

TimeTicks trUtil::Timer::Tick ( )
inline

Get the timers tick value.

Returns
The TimeTicks.

Definition at line 100 of file Timer.h.

Referenced by trCore::SceneObjects::RingArrayCallback::operator()(), trCore::SystemDirector::Run(), and trCore::SystemDirector::RunOnce().

Here is the caller graph for this function:

Member Data Documentation

◆ mCustomTicks

TimeTicks trUtil::Timer::mCustomTicks = 0
private

Definition at line 238 of file Timer.h.

Referenced by SetStartTick().

◆ mNewTicks

TimeTicks trUtil::Timer::mNewTicks = 0
private

Definition at line 237 of file Timer.h.

Referenced by SetStartTick().

◆ mOldTicks

TimeTicks trUtil::Timer::mOldTicks = 0
private

Definition at line 236 of file Timer.h.

Referenced by SetStartTick().

◆ mTimer

osg::Timer trUtil::Timer::mTimer
private

Definition at line 235 of file Timer.h.

Referenced by SetStartTick().


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