vibe.web_core.utils

Timing utilities for web request instrumentation.

record_timing_block

record_timing_block(key: str) -> Iterator[None]

Record the execution time of a block of code.

Store the duration in milliseconds in g.timings under the provided key. Require g.timings to be initialized (usually in a before_request handler).

Usage

with record_timings("my_operation"): # Code to time do_something()

record_timings

record_timings(func: Callable[..., T]) -> Callable[..., T]

Record the execution time of a function.

Use the function's name (func.__name__) as the key for storing the duration in milliseconds in g.timings. Require g.timings to be initialized. Use the record_timing_block context manager internally.

Usage

@record_timings def my_function(arg1, arg2): # ... function body ... pass