From e6e244cdb0af483b90c37ff075cae5184dcda84b Mon Sep 17 00:00:00 2001
From: lukas leufen <l.leufen@fz-juelich.de>
Date: Wed, 8 Apr 2020 17:11:01 +0200
Subject: [PATCH] new time tracking wrapper to use as decorator

---
 src/helpers.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/helpers.py b/src/helpers.py
index e977c9ae..be736143 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
-- 
GitLab