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. | |
|
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 since this instance was created or reset. If no measurement was performed, the result value will be set to 0 ticks.
result | An object to store the result in. If not provided (null), a result object is created. |
|
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!
|
inline |
|
inline |
Returns the internally stored value.
|
inline |
Sets the internal value to current system time and clears existing sum and quantity of samples.
|
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.
|
inline |
Sets the internal start time value.
t | The value. |
|
inline |
Sets the internal value to current system time to 'now'.
|
inline |
Returns a String that represents this object.