mirror of https://github.com/Yomguithereal/fog.git
14 lines
335 B
Python
14 lines
335 B
Python
from timeit import default_timer as timer
|
|
|
|
class Timer(object):
|
|
def __init__(self, name='Timer'):
|
|
self.name = name
|
|
|
|
def __enter__(self):
|
|
self.start = timer()
|
|
|
|
def __exit__(self, *args):
|
|
self.end = timer()
|
|
self.duration = self.end - self.start
|
|
print('%s:' % self.name, self.duration)
|