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