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 ()
 

Protected Fields

int cntSamples
 
Ticks sum = new Ticks( 0L )
 
Ticks tempTicks
 
Ticks ticks = new Ticks( 0L )
 

Constructor & Destructor Documentation

◆ TickWatch() [1/2]

TickWatch ( )

Creates a TickWatch representing the current point in time.

◆ TickWatch() [2/2]

TickWatch ( TickWatch  copy)

Creates a TickWatch as a copy of another TickWatch.

Parameters
copyThe instance to copy value from.

Member Function Documentation

◆ getAverage() [1/2]

Ticks getAverage ( )

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 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)

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 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 ( )

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 ( )

Returns the number of calls to sample since this instance was created or reset was invoked.

Returns
The number of samples.

◆ getStartTime()

Ticks getStartTime ( )

Returns the internally stored value.

Returns
the internally stored Ticks value.

◆ reset()

void reset ( )

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

◆ sample()

Ticks sample ( )

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)

Sets the internal time value. This affects both, the reference value for the calculation of this TickWatchs age in subsequent calls, as well as subsequent sample time spans.

Parameters
tThe value.

◆ start()

void start ( )

Sets the internal value to current system time. This affects both, the reference value for the calculation of this TickWatchs age in subsequent calls, as well as subsequent sample time spans.

Member Data Documentation

◆ cntSamples

int cntSamples
protected

The number of samples performed.

◆ sum

Ticks sum = new Ticks( 0L )
protected

The sum of the samples times.

◆ tempTicks

Ticks tempTicks
protected

A temporary Ticks used as a return value

◆ ticks

Ticks ticks = new Ticks( 0L )
protected

The value.


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