Skip to main content

StopWatch

No overview available.

Methods


Start()

@classmethod
def Start(
ctx: context.Context
) - > Timer

Starts a new timer to measure the duration of an operation. Callers use this to begin timing an event.

Parameters

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

Returns

TypeDescription
TimerA 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 specific duration between a start and end time. Callers use this to manually record an already completed time interval.

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 observed duration.
endtime.TimeThe ending timestamp of the observed duration.

Time()

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

Executes a given function and measures its execution time. Callers use this to conveniently time the execution of a block of code.

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.