CounterTiming

Callback object returned by ICounters.begin_timing to end the timing of an execution block and update the associated counter.

Description

The CounterTiming class allows you to create callback objects that are returned by ICounters.begin_timing to end the timing of execution blocks and update the associated counters.

Constructors

Creates a new instance of the timing callback object.

CounterTiming(counter: str = None, callback: ICounterTimingCallback = None)

  • counter: str - an associated counter name
  • callback: ICounterTimingCallback - a callback that shall be called when end_timing is called.

Fields

_counters

A list containing different counters

_counters: List[ICounters] = []

Instance methods

end_timing

Ends timing of an execution block, calculates elapsed time and updates the associated counter.

end_timing()

Examples

timing = counters.begin_timing("mymethod.exec_time")
# do something
timing.end_timing()