2023-08-27 23:43:45 +00:00
|
|
|
from time import time
|
|
|
|
|
|
|
|
|
|
|
|
async def log_time_async(method: callable, **kwargs):
|
|
|
|
start = time()
|
|
|
|
result = await method(**kwargs)
|
|
|
|
secs = f"{round(time() - start, 2)} secs"
|
|
|
|
if result:
|
|
|
|
return " ".join([result, secs])
|
|
|
|
return secs
|
|
|
|
|
|
|
|
|
|
|
|
def log_time_yield(method: callable, **kwargs):
|
|
|
|
start = time()
|
|
|
|
result = yield from method(**kwargs)
|
|
|
|
yield f" {round(time() - start, 2)} secs"
|
|
|
|
|
|
|
|
|
|
|
|
def log_time(method: callable, **kwargs):
|
|
|
|
start = time()
|
|
|
|
result = method(**kwargs)
|
|
|
|
secs = f"{round(time() - start, 2)} secs"
|
|
|
|
if result:
|
|
|
|
return " ".join([result, secs])
|
2023-09-17 21:38:55 +00:00
|
|
|
return secs
|