Table of Contents

Class ConcurrentTimeCounter

Namespace
Hi.Common
Assembly
HiGeom.dll

Thread-safe utility for measuring and tracking execution time across multiple tasks.

public static class ConcurrentTimeCounter
Inheritance
ConcurrentTimeCounter
Inherited Members

Remarks

This is the concurrent version of TimeCounter, designed for multi-threaded environments. It measures the time elapsed between paired calls to Bound(object) with the same key in the same task. The timing starts on the first (odd-numbered) call to Bound(object) and stops on the second (even-numbered) call, accumulating statistics for each key.

Methods

Bound(object)

Marks a boundary for time measurement for the specified key.

public static void Bound(object key)

Parameters

key object

The key to identify this measurement

Remarks

This method acts as both the start and end point for timing:

  • On first call with a key, starts the timer
  • On second call with the same key, stops the timer and records the elapsed time
  • Subsequent calls alternate between starting and stopping

Pass(object)

Cancels an active time measurement for the specified key without recording the elapsed time.

public static void Pass(object key)

Parameters

key object

The key identifying the measurement to cancel

Remarks

If timing has not been started for the key, this method has no effect. This is useful when you want to abort a measurement without affecting statistics.

Reset()

Resets all time measurements across all tasks. Clears 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 task and key, shows the count of measurements, total time, and average time.

ShowExt(int)

Displays time measurements and resets counters periodically based on call frequency.

public static void ShowExt(int gap)

Parameters

gap int

The number of calls to this method before showing results and resetting

Remarks

This method increments an internal counter with each call. When the counter reaches the specified gap value, it displays all measurements, resets the counters, and resets the internal counter to zero.