Skip to main content

StopWatch

No overview available.

Methods


Start()

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

Starts a new timer for measuring the duration of an operation. Callers use this to begin timing a specific code block or event.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, used to carry 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 a duration between a start and end time. Callers use this to manually record the duration of an operation that has already completed.

Parameters

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

Time()

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

Executes a given function and automatically records its execution duration. Callers use this for convenient timing of functions without manual start/stop calls.

Parameters

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