PTimer Class Reference

Detailed Description

The PTimer class provides a high precision chronometer (highest precision available on the host).

PTimer records up to N measures (100 by default). A new measure is added each time you call Stop(). See Min(), Max(), Average().

Definition at line 28 of file PTimer.h.

#include <PTimer.h>

Constructor & Destructor Documentation

◆ PTimer() [1/2]

PTimer::PTimer ( papillon::int32  keepNMostRecentMeasures = 100)

Constructs a timer and starts it immediately.

Keeps the N most recent measures (100 by default).

See also
Start()

◆ ~PTimer()

virtual PTimer::~PTimer ( )
virtual

Destroys this object.

◆ PTimer() [2/2]

PTimer::PTimer ( const PTimer other)

Constructs a shared copy of other.

Member Function Documentation

◆ Average()

double PTimer::Average ( ) const

Returns the average time recorded by this timer.

Return NaN if no time recorded.

◆ ElapsedMs()

double PTimer::ElapsedMs ( ) const

Returns the current number of milliseconds elapsed since the last Start().

Do not record this time. The timer continues running.

See also
ElapsedSec()
Start()

◆ ElapsedSec()

double PTimer::ElapsedSec ( ) const

Returns the current number of seconds elapsed since the last Start().

Do not record this time. The timer continues running.

See also
ElapsedMs()
Start()

◆ ElapsedToString()

PString PTimer::ElapsedToString ( ) const

Returns the time elapsed since the last start as a string with format "DAYS:HH:MM:SS,MS".

◆ Get()

double PTimer::Get ( papillon::int32  n) const

Returns the nth recorded time or NaN if there is no nth record.

◆ Max()

double PTimer::Max ( ) const

Returns the greatest time recorded by this timer.

Return NaN if no time recorded.

◆ Min()

double PTimer::Min ( ) const

Returns the smallest time recorded by this timer.

Return NaN if no time recorded.

◆ operator=()

PTimer& PTimer::operator= ( const PTimer other)

Performs a shared copy of other to this object.

◆ Reset()

void PTimer::Reset ( )

Removes all registered times.

◆ Size()

papillon::int32 PTimer::Size ( ) const

Returns the number of measures stored in this timer.

◆ Start()

void PTimer::Start ( )

Starts/Restarts this chronometer.

See also
Stop()
ElapsedSec()

◆ Stop()

double PTimer::Stop ( )

Returns the current number of seconds elapsed since the last Start() and records this time.

The timer is restarted after Stop().

You can retrieve some statistics about recording times using Min(), Max(), Average().

See also
Start()
ElapsedSec()
Reset()