biogeme.tools.time module¶
- class biogeme.tools.time.Timing(warm_up_runs=10, num_runs=100)[source]¶
Bases:
objectCall for timing the execution of callable functions
- Parameters:
warm_up_runs (int)
num_runs (int)
- property num_runs: int¶
- time_function(callable_func, kwargs)[source]¶
Times the execution of a callable function, excluding the warm-up period.
- Parameters:
callable_func (
Callable) – The function to be timed.kwargs (
dict[str,Any]) – Dictionary of keyword arguments to pass to the function. Note that all arguments must be with keyword
- Return type:
float- Returns:
Average time per run.
- property warm_up_runs: int¶
- biogeme.tools.time.format_elapsed_time(ms)[source]¶
Convert a duration in milliseconds into a human-readable string.
- Return type:
str- Parameters:
ms (float)
Examples¶
>>> format_elapsed_time(250) '250 ms' >>> format_elapsed_time(3125) '3.13 s' >>> format_elapsed_time(65_000) '1.08 min' >>> format_elapsed_time(3_600_000) '1.00 h' >>> format_elapsed_time(172_800_000) '2.00 days'