# Copyright (c) PARRRATE T&V 2021. All rights reserved. import time __all__ = ('TimeSample',) 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()