Class TimeCounter
A utility counts the average/total time consume between the Bound(object) areas. The count of time consume for the given key starts at the first time (and the odd time) calling Bound(object); stops and accumulates at the second time (and the even time).
public static class TimeCounter
- Inheritance
-
TimeCounter
- Inherited Members
Methods
Bound(object)
Marks a boundary for time measurement for the specified key.
public static void Bound(object key)
Parameters
key
objectThe key that identifies this particular measurement.
Remarks
This method alternates between starting and stopping time measurement:
- First call with a key: Starts the timer
- Second call with the same key: Stops the timer and records the elapsed time
- Third call: Starts the timer again
- And so on…
The elapsed time is accumulated and the count is incremented each time a measurement completes.
Pass(object)
Cancels an active time measurement for the specified key without recording the elapsed time.
public static void Pass(object key)
Parameters
key
objectThe key that identifies the measurement to cancel.
Remarks
If timing has not been started for the specified key, this method has no effect. This is useful for aborting a measurement without affecting statistics.
Reset()
Resets all time measurements by clearing all accumulated statistics and counters.
public static void Reset()
Show()
Displays all accumulated time measurements to the console.
public static void Show()
Remarks
For each key, this method outputs:
- The count of measurements
- The total accumulated time
- The average time per measurement
- The key identifier
ShowExt(int)
Displays time measurements and resets counters periodically based on call frequency.
public static void ShowExt(int gap)
Parameters
gap
intThe number of calls to this method before showing results and resetting.