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