log_function_time.py 348 B

1234567891011121314151617
  1. from tts_webui.magnet.utils import Timer
  2. def log_function_time(fn):
  3. def wrapper(*args, **kwargs):
  4. with Timer():
  5. return fn(*args, **kwargs)
  6. return wrapper
  7. def log_generator_time(generator):
  8. def wrapper(*args, **kwargs):
  9. with Timer():
  10. yield from generator(*args, **kwargs)
  11. return wrapper