misc.py 397 B

1234567891011121314151617
  1. from functools import wraps
  2. from time import time
  3. def exec_time(func):
  4. @wraps(func)
  5. async def _time_it(*args, **kwargs):
  6. t1 = time()
  7. try:
  8. return await func(*args, **kwargs)
  9. finally:
  10. t2 = time()
  11. total = t2 - t1
  12. total = round(total, 3)
  13. print(f"{func.__name__} Took: {total} Seconds")
  14. return _time_it