libtimer: timing functions

Tools related to timing functions.

haddock.libs.libtimer.convert_seconds_to_min_sec(seconds: float) str[source]

Convert seconds to min&sec.

Examples

>>> convert_seconds_to_min_sec(60)
1 minute
>>> convert_seconds_to_min_sec(120)
2 minutes and 0 seconds
>>> convert_seconds_to_min_sec(179)
2 minutes and 59 seconds
Parameters:

seconds (int) – The elapsed time in seconds. Seconds are round to integers.

Returns:

str

haddock.libs.libtimer.log_time(pre_msg: str) Generator[None, None, None][source]

Log the time taken to execute the code under the context.

Examples

>>> with log_time("function took"):
    do_something()
    do_more()

logged: “function tooked 10 minutes”

Parameters:

pre_msg (str) – String to log with appended time.