ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::time::StopWatch Class Reference

Description:

This class encapsulates a system dependent timer value of type Ticks and provides some simple interface for measuring multiple time spans and providing their sum, average, minimum and maximum.

See also
For this class, a pretty printer for the GNU debugger is provided.

Definition at line 19 of file stopwatch.inl.

Collaboration diagram for alib::time::StopWatch:
[legend]

Public Method Index:

 StopWatch ()
 Creates a started StopWatch.
 
Ticks::Duration GetAverage () const
 
Ticks::Duration GetCumulated () const
 
Ticks::Duration GetMaximum () const
 
Ticks::Duration GetMinimum () const
 
int GetSampleCnt () const
 
TicksGetStartTime ()
 
void Reset ()
 
Ticks::Duration Sample ()
 
void Start ()
 

Protected Field Index:

int cntSamples =0
 The number of samples performed.
 
Ticks::Duration max
 The maximum duration probed.
 
Ticks::Duration min
 The minimum duration probed.
 
Ticks startTime
 The current start time.
 
Ticks::Duration sum
 The sum of the samples times.
 

Field Details:

◆ cntSamples

int alib::time::StopWatch::cntSamples =0
protected

The number of samples performed.

Definition at line 27 of file stopwatch.inl.

◆ max

Ticks::Duration alib::time::StopWatch::max
protected

The maximum duration probed.

Definition at line 36 of file stopwatch.inl.

◆ min

Ticks::Duration alib::time::StopWatch::min
protected

The minimum duration probed.

Definition at line 33 of file stopwatch.inl.

◆ startTime

Ticks alib::time::StopWatch::startTime
protected

The current start time.

Definition at line 24 of file stopwatch.inl.

◆ sum

Ticks::Duration alib::time::StopWatch::sum
protected

The sum of the samples times.

Definition at line 30 of file stopwatch.inl.

Constructor(s) / Destructor Details:

◆ StopWatch()

alib::time::StopWatch::StopWatch ( )
inline

Creates a started StopWatch.

Definition at line 43 of file stopwatch.inl.

Method Details:

◆ GetAverage()

Ticks::Duration alib::time::StopWatch::GetAverage ( ) const
inline

Returns the average time of all samples since this instance was created or reset. If no measurement was performed, the result value will be set to 0.

Returns
The cumulated measured time.

Definition at line 131 of file stopwatch.inl.

◆ GetCumulated()

Ticks::Duration alib::time::StopWatch::GetCumulated ( ) const
inline

Returns the cumulated time of all samples taken since this instance was created or cleared.

Returns
The cumulated measured time.

Definition at line 120 of file stopwatch.inl.

◆ GetMaximum()

Ticks::Duration alib::time::StopWatch::GetMaximum ( ) const
inline

Returns the maximum duration of all samples since this instance was created or reset. If no measurement was performed, the value evaluates to the maximum value storable in type Ticks::Duration.

Returns
The maximum measured duration.

Definition at line 156 of file stopwatch.inl.

◆ GetMinimum()

Ticks::Duration alib::time::StopWatch::GetMinimum ( ) const
inline

Returns the minimum duration of all samples since this instance was created or reset. If no measurement was performed, the value evaluates to the minmum value storable in type Ticks::Duration.

Returns
The minimum measured duration.

Definition at line 144 of file stopwatch.inl.

◆ GetSampleCnt()

int alib::time::StopWatch::GetSampleCnt ( ) const
inline

Returns the number of calls to Sample since this instance was created or Reset was invoked.

Returns
The number of samples.

Definition at line 109 of file stopwatch.inl.

◆ GetStartTime()

Ticks & alib::time::StopWatch::GetStartTime ( )
inline

Provides access to the internal start time.

Returns
The start time

Definition at line 53 of file stopwatch.inl.

◆ Reset()

void alib::time::StopWatch::Reset ( )
inline

Sets the internal value to current system time and clears existing sum and quantity of samples.

Definition at line 72 of file stopwatch.inl.

Here is the call graph for this function:

◆ Sample()

Ticks::Duration alib::time::StopWatch::Sample ( )
inline

Returns the time span between the current system time and the internal start value. In addition this value is added to the sum of sample times and the sample counter is increased by one. Lastly the internal reference value is set to now. Therefore, a subsequent call to this function would measure the time span from this call to this subsequent call (if the internal start time value was not set differently meanwhile).

Returns
The time difference between the current system time and the internal reference value.

Definition at line 92 of file stopwatch.inl.

Here is the call graph for this function:

◆ Start()

void alib::time::StopWatch::Start ( )
inline

Sets the start time to now. This affects both, the reference value for the calculation of this StopWatch's age in subsequent calls, as well as subsequent sample time spans.

Definition at line 63 of file stopwatch.inl.

Here is the call graph for this function:

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