Skip to content

Commit c05b527

Browse files
committed
fix bug in AvgTimer
1 parent 0bd2758 commit c05b527

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

basicsr/utils/logger.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,23 @@ def __init__(self, window=200):
1818
self.start()
1919

2020
def start(self):
21-
self.start_time = time.time()
21+
self.start_time = self.tic = time.time()
2222

2323
def record(self):
2424
self.count += 1
25-
self.current_time = time.time() - self.start_time
25+
self.toc = time.time()
26+
self.current_time = self.toc - self.tic
2627
self.total_time += self.current_time
2728
# calculate average time
2829
self.avg_time = self.total_time / self.count
30+
2931
# reset
3032
if self.count > self.window:
3133
self.count = 0
3234
self.total_time = 0
3335

36+
self.tic = time.time()
37+
3438
def get_current_time(self):
3539
return self.current_time
3640

0 commit comments

Comments
 (0)