1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-29 02:55:52 +00:00
bazarr/libs/wraptor/context/timer.py
2018-10-31 17:08:29 +01:00

18 lines
435 B
Python

import time
class timer(object):
__slots__ = ('name', 'interval', 'start', 'end')
def __init__(self, name=None):
self.name = name
def __enter__(self):
self.start = time.time() * 1e3
return self
def __exit__(self, *args):
self.end = time.time() * 1e3
self.interval = self.end - self.start
def __str__(self):
return "%s took %.03f ms" % (self.name, self.interval)