quantlab.utils.timer.Timer#

class quantlab.utils.timer.Timer(task_name)[source]#

Bases: object

Log the start of a task on entry and its elapsed wall-clock time on exit.

Parameters:
task_namestr

Name used in both log lines.

Attributes:
timeinfloat

Elapsed seconds of the last completed block; 0 before any block has finished.

Examples

>>> with Timer("compute factors") as timer:
...     panel = factor.compute("2024-01-01", "2024-06-30")
>>> elapsed_seconds = timer.timein