Skip to main content

HistogramStopWatch

No overview available.

Methods


Start()

@classmethod
def Start(
ctx: context.Context
) - > [Timer](timer.md?sid=flytestdlib_promutils_labeled_timer)

Starts a timer for measuring the duration of an operation. This method should be called at the beginning of the operation to obtain a Timer object.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, used for propagating deadlines, cancellation signals, and other request-scoped values.

Returns

TypeDescription
[Timer](timer.md?sid=flytestdlib_promutils_labeled_timer)A Timer object that can be used to record the elapsed time.

Observe()

@classmethod
def Observe(
ctx: context.Context,
start: time.Time,
end: time.Time
)

Records the duration of an operation given explicit start and end times. This method is useful when the timing is managed externally or needs to be reported after the fact.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, used for propagating deadlines, cancellation signals, and other request-scoped values.
starttime.TimeThe starting timestamp of the operation.
endtime.TimeThe ending timestamp of the operation.

Time()

@classmethod
def Time(
ctx: context.Context,
f: func()
)

Executes a given function and automatically records its execution duration. This method simplifies timing by handling the start and end of the measurement internally.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, used for propagating deadlines, cancellation signals, and other request-scoped values.
ffunc()The function to be executed and timed.