dppo/util/timer.py
2024-09-03 21:03:27 -04:00

20 lines
348 B
Python

"""
Simple timer from https://github.com/jannerm/diffuser/blob/main/diffuser/utils/timer.py
"""
import time
class Timer:
def __init__(self):
self._start = time.time()
def __call__(self, reset=True):
now = time.time()
diff = now - self._start
if reset:
self._start = now
return diff