You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/libs/wraptor/context/timer.py

19 lines
435 B

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)