class RED::Timer

Timer class. More...

#include <REDTimer.h>

Inherits: Object.

Public functions:

Timer ( )
virtual ~Timer ( )
virtual void *As ( const RED::CID & iCID )
virtual const void *As ( const RED::CID & iCID ) const
template< class T_As > const T_As *As ( ) const
template< class T_As > T_As *As ( )
boolIsStarted ( ) const
floatMSElapsed ( ) const
floatSecondsElapsed ( ) const
RED_RCStart ( )

Public static functions:

static RED::CIDGetClassID ( )

Protected variables:

__int64_freq
__int64_start

Detailed description:

Timer class.

Use RED::Timer::Start to initialize a measure. Use RED::Timer::MSElapsed to get the elapsed time since the last call to Start in milliseconds (or RED::Timer::SecondsElapsed in seconds). Note that there's no threading management in this class.

It's possible that the timer fails to initialize on certain CPUs (on windows platforms: Those that do not support high resolution performance counters). If this case occurs, any call to RED::Timer::Start will return a RED_INIT_FAILED, and measurement methods are all to return negative invalid values.

Functions documentation

Timer construction method.

This constructor calibrates the timer.

public virtual RED::Timer::~Timer()

Timer destruction method.

public virtual void * RED::Timer::As(const RED::CID &iCID)

Converts the object to an instance of the given type.

Parameters:

iCID:Requested class.

Returns:

An object pointer of the given class on success, NULL otherwise.

Reimplements: RED::Object::As.

public virtual const void * RED::Timer::As(const RED::CID &iCID) const

Converts the object to an instance of the given type.

Parameters:

iCID:Requested class.

Returns:

An object pointer of the given class on success, NULL otherwise.

Reimplements: RED::Object::As.

template< class T_As > public const T_As * RED::Timer::As() const

Template version of the as const method.

Simply set T to be the class you want to retrieve an interface to.

Returns:

A pointer to a const instance of class T on success, NULL otherwise.

Reimplements: RED::Object::As.

template< class T_As > public T_As * RED::Timer::As()

Template version of the as method.

Simply set T to be the class you want to retrieve an interface to.

Returns:

A pointer to an instance of class T on success, NULL otherwise.

Reimplements: RED::Object::As.

public bool RED::Timer::IsStarted() const

Do we have started a time record?

Returns:

true if we are between a RED::Timer::Start and an xxxElapsed call, false otherwise.
public float RED::Timer::MSElapsed() const

Gives time elapsed since last RED::Timer::Start call, in milliseconds.

This method returns the time elapsed since last call to RED::Timer::Start, in milliseconds. If Start has not ever been called before, the method returns 0.0f.

Returns:

The number of milliseconds elapsed.
public float RED::Timer::SecondsElapsed() const

Gives time elapsed since last RED::Timer::Start call, in seconds.

This method returns the time elapsed since last call to RED::Timer::Start, in seconds. If Start has not ever been called before, the method returns 0.0f.

Returns:

The number of seconds elapsed.

Measures time starting now.

Sets the timer's time reference to the moment of the call.

Returns:

RED_INIT_FAILED if the timer failed to initialize,
RED_OK when the operation succeeded,
RED_FAIL in case of an unexpected failure.

Variables documentation

protected __int64 RED::Timer::_freq

High performance counters per second. Calculated at instance allocation time only.

protected __int64 RED::Timer::_start

Time recorded during the last call to RED::Timer::Start.