builtup4/timesample.py
2021-07-24 02:34:37 +03:00

19 lines
382 B
Python

import time
class TimeSample:
level = 0
def __init__(self, *args):
self.args = args
def __enter__(self):
TimeSample.level += 1
self.__t = time.time()
def __exit__(self, exc_type, exc_val, exc_tb):
TimeSample.level -= 1
print(' ' * 4 * self.level, end='')
print(*self.args, time.time() - self.__t)
print()