diff --git a/src/agora/logging_timer.py b/src/agora/logging_timer.py new file mode 100644 index 0000000000000000000000000000000000000000..6eb1bea655c355ea8fa07dd157f602ac2444a645 --- /dev/null +++ b/src/agora/logging_timer.py @@ -0,0 +1,16 @@ +import logging +from time import perf_counter + + +def timer(func): + """Log duration of a function into the aliby log file.""" + + def wrap_func(*args, **kwargs): + t1 = perf_counter() + result = func(*args, **kwargs) + logging.getLogger("aliby").debug( + f"{func.__qualname__} took {(perf_counter()-t1):.4f}s" + ) + return result + + return wrap_func