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
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used to carry deadlines, cancellation signals, and other request-scoped values. |
Returns
| Type | Description |
|---|---|
[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
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used to carry deadlines, cancellation signals, and other request-scoped values. |
| start | time.Time | The starting timestamp of the operation to be observed. |
| end | time.Time | The 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
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used to carry deadlines, cancellation signals, and other request-scoped values. |
| f | func() | The function to be executed and timed. |