diff --git a/src/helpers.py b/src/helpers.py index e977c9ae0da53c640405aa376a593281b485f46d..be73614319b39dc36043437c64379342a96ce00e 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -5,6 +5,7 @@ __date__ = '2019-10-21' import datetime as dt +from functools import wraps import logging import math import os @@ -43,6 +44,16 @@ def l_p_loss(power: int): return loss +class TimeTrackingWrapper: + + def __init__(self, func): + wraps(func)(self) + + def __call__(self, *args, **kwargs): + with TimeTracking(name=self.__wrapped__.__name__): + return self.__wrapped__(*args, **kwargs) + + class TimeTracking(object): """ Track time to measure execution time. Time tracking automatically starts on initialisation and ends by calling stop