TimesTracker.iter_time()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nop 1
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