maple.utils.timeout.OperationTimer

class maple.utils.timeout.OperationTimer(operation: str, expected: float = 1.0, warn_threshold: float = 2.0, log_always: bool = False)

Timer for tracking operation duration and detecting slow operations.

Logs warnings when operations exceed expected duration.

Example:

timer = OperationTimer(“Policy inference”, expected=1.0, warn_threshold=2.0) with timer:

action = policy.act(obs)

print(f”Took {timer.elapsed:.2f}s”)

Methods

__init__(operation[, expected, ...])

Initialize operation timer.

Attributes

elapsed

Get elapsed time in seconds.