ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
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 23 of file stopwatch.hpp.

#include <stopwatch.hpp>

Collaboration diagram for 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 cntSamples =0
protected

The number of samples performed.

Definition at line 31 of file stopwatch.hpp.

◆ max

Ticks::Duration max
protected

The maximum duration probed.

Definition at line 40 of file stopwatch.hpp.

◆ min

Ticks::Duration min
protected

The minimum duration probed.

Definition at line 37 of file stopwatch.hpp.

◆ startTime

Ticks startTime
protected

The current start time.

Definition at line 28 of file stopwatch.hpp.

◆ sum

Ticks::Duration sum
protected

The sum of the samples times.

Definition at line 34 of file stopwatch.hpp.

Constructor(s) / Destructor Details:

◆ StopWatch()

StopWatch ( )
inline

Creates a started StopWatch.

Definition at line 47 of file stopwatch.hpp.

Method Details:

◆ GetAverage()

Ticks::Duration 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 135 of file stopwatch.hpp.

◆ GetCumulated()

Ticks::Duration 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 124 of file stopwatch.hpp.

◆ GetMaximum()

Ticks::Duration 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 160 of file stopwatch.hpp.

◆ GetMinimum()

Ticks::Duration 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 148 of file stopwatch.hpp.

◆ GetSampleCnt()

int 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 113 of file stopwatch.hpp.

◆ GetStartTime()

Ticks & GetStartTime ( )
inline

Provides access to the internal start time.

Returns
The start time

Definition at line 57 of file stopwatch.hpp.

◆ Reset()

void Reset ( )
inline

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

Definition at line 76 of file stopwatch.hpp.

Here is the call graph for this function:

◆ Sample()

Ticks::Duration 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 96 of file stopwatch.hpp.

Here is the call graph for this function:

◆ Start()

void 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 67 of file stopwatch.hpp.

Here is the call graph for this function:

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