biogeme.tools.timeit_decorator module

biogeme.tools.timeit_decorator.timeit_old(logger=None, level=20, label=None, threshold_ms=10.0)[source]

Decorator factory that measures wall-clock time of a function and reports it only if the elapsed time exceeds a threshold.

Return type:

Callable[[TypeVar(F, bound= Callable[..., Any])], TypeVar(F, bound= Callable[..., Any])]

Parameters:
  • logger (Logger | None)

  • level (int)

  • label (str | None)

  • threshold_ms (float)

Args:

logger: Logger to use (default: None -> print). level: Logging level if logger is provided. label: Optional label to override function.__qualname__ in the message. threshold_ms: Minimum duration (in milliseconds) to report (default: 10.0).

Usage:

@timeit() # prints if >10 ms @timeit(threshold_ms=1.0) # prints if >1 ms @timeit(logging.getLogger()) # logs instead of printing @timeit(label=”my_step”) # custom label