ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Methods | Protected Fields | List of all members
StopWatch Class Reference

#include <stopwatch.hpp>

Collaboration diagram for StopWatch:
[legend]

Class 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.

Definition at line 22 of file stopwatch.hpp.

Public Methods

 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 Fields

int cntSamples =0
 
Ticks::Duration max
 
Ticks::Duration min
 
Ticks startTime
 
Ticks::Duration sum
 

Constructor & Destructor Documentation

◆ StopWatch()

StopWatch ( )
inline

Creates a started StopWatch.

Definition at line 46 of file stopwatch.hpp.

Member Function Documentation

◆ 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 134 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 123 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 159 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 147 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 112 of file stopwatch.hpp.

◆ GetStartTime()

Ticks& GetStartTime ( )
inline

Provides access to the internal start time.

Returns
The start time

Definition at line 56 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 75 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 95 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 66 of file stopwatch.hpp.

Here is the call graph for this function:

Member Data Documentation

◆ cntSamples

int cntSamples =0
protected

The number of samples performed.

Definition at line 30 of file stopwatch.hpp.

◆ max

Ticks::Duration max
protected

The maximum duration probed.

Definition at line 39 of file stopwatch.hpp.

◆ min

Ticks::Duration min
protected

The minimum duration probed.

Definition at line 36 of file stopwatch.hpp.

◆ startTime

Ticks startTime
protected

The current start time.

Definition at line 27 of file stopwatch.hpp.

◆ sum

Ticks::Duration sum
protected

The sum of the samples times.

Definition at line 33 of file stopwatch.hpp.


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