gradient_free_optimizers._times_tracker   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 21
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A TimesTracker.eval_time() 0 8 1
A TimesTracker.iter_time() 0 8 1
A TimesTracker.__init__() 0 5 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