ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Methods | Protected Fields | List of all members
TickWatch Class Reference
Collaboration diagram for TickWatch:
[legend]

Class Description


This class encapsulates a system dependent time value (Ticks) and provides some basic interface for measuring time spans, including multiple samples and their average.

The interface does provide nanosecond versions the methods. However, the internal resolution of the used timer is system dependent and might be lower than nanoseconds.

Public Methods

 TickWatch ()
 
 TickWatch (TickWatch copy)
 
Ticks GetAverage ()
 
Ticks GetAverage (Ticks result)
 
Ticks GetCumulated ()
 
int GetSampleCnt ()
 
Ticks GetStartTime ()
 
void Reset ()
 
Ticks Sample ()
 
void SetStartTime (Ticks t)
 
void Start ()
 
override String ToString ()
 

Protected Fields

int cntSamples = 0
 The number of samples performed.
 
Ticks sum =new Ticks( 0L )
 The sum of the samples times.
 
Ticks tempTicks
 A temporary Ticks used as a return value.
 
Ticks ticks =new Ticks( 0L )
 The value.
 

Constructor & Destructor Documentation

◆ TickWatch() [1/2]

TickWatch ( )
inline

Creates a TickWatch representing the current point in time.

◆ TickWatch() [2/2]

TickWatch ( TickWatch  copy)
inline

Creates a TickWatch as a copy of another TickWatch.

Parameters
copyThe instance to copy value from.

Member Function Documentation

◆ GetAverage() [1/2]

Ticks GetAverage ( )
inline

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

Note: Attention: The object returned is a temporary object, deemed to be reused by other interface methods of this instance. Therefore, it must be used only until subsequent method invocations on this instance are performed (hence, also not thread safe!) Use GetAverage(Ticks result) to provide a dedicated external result instance.

Returns
The average length of all samples taken since the last reset.

◆ GetAverage() [2/2]

Ticks GetAverage ( Ticks  result)
inline

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

Parameters
resultAn object to store the result in. If not provided (null), a result object is created.
Returns
The average sample time within the given or created object.

◆ GetCumulated()

Ticks GetCumulated ( )
inline

Returns the cumulated length of all samples taken since this instance was created or cleared. Note: the object returned will be reused in subsequent calls to this method. Hence, previously returned values will be overwritten!

Returns
The cumulated length of all samples taken since the last reset.

◆ GetSampleCnt()

int GetSampleCnt ( )
inline

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

Returns
The number of samples taken.

◆ GetStartTime()

Ticks GetStartTime ( )
inline

Returns the internally stored value.

Returns
The internally stored value in ticks..

◆ Reset()

void Reset ( )
inline

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

◆ Sample()

Ticks Sample ( )
inline

Returns the time span between the current system time and the internal reference 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 reference value was not set differently meanwhile). Other interface methods dealing with samples are GetSampleCnt, GetCumulated and GetAverage.

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

◆ SetStartTime()

void SetStartTime ( Ticks  t)
inline

Sets the internal start time value.

Parameters
tThe value.

◆ Start()

void Start ( )
inline

Sets the internal value to current system time to 'now'.

◆ ToString()

override String ToString ( )
inline

Returns a String that represents this object.

Returns
A String that represents this object.

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