Skip to content

Commit

Permalink
fix bug in AvgTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
xinntao committed Dec 12, 2021
1 parent 0bd2758 commit c05b527
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions basicsr/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ def __init__(self, window=200):
self.start()

def start(self):
self.start_time = time.time()
self.start_time = self.tic = time.time()

def record(self):
self.count += 1
self.current_time = time.time() - self.start_time
self.toc = time.time()
self.current_time = self.toc - self.tic
self.total_time += self.current_time
# calculate average time
self.avg_time = self.total_time / self.count

# reset
if self.count > self.window:
self.count = 0
self.total_time = 0

self.tic = time.time()

def get_current_time(self):
return self.current_time

Expand Down

0 comments on commit c05b527

Please sign in to comment.