| Total Complexity | 3 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # Author: Simon Blanke |
||
| 2 | # Email: [email protected] |
||
| 3 | # License: MIT License |
||
| 4 | |||
| 5 | import time |
||
| 6 | |||
| 7 | |||
| 8 | class TimesTracker: |
||
| 9 | def __init__(self): |
||
| 10 | super().__init__() |
||
| 11 | |||
| 12 | self.eval_times = [] |
||
| 13 | self.iter_times = [] |
||
| 14 | |||
| 15 | def eval_time(func): |
||
| 16 | def wrapper(self, *args, **kwargs): |
||
| 17 | t = time.time() |
||
| 18 | res = func(self, *args, **kwargs) |
||
| 19 | self.eval_times.append(time.time() - t) |
||
| 20 | return res |
||
| 21 | |||
| 22 | return wrapper |
||
| 23 | |||
| 24 | def iter_time(func): |
||
| 25 | def wrapper(self, *args, **kwargs): |
||
| 26 | t = time.time() |
||
| 27 | res = func(self, *args, **kwargs) |
||
| 28 | self.iter_times.append(time.time() - t) |
||
| 29 | return res |
||
| 30 | |||
| 31 | return wrapper |
||
| 32 |