2023-08-28 02:43:45 +03: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"
|
2023-10-23 10:46:25 +03:00
|
|
|
return " ".join([result, secs]) if result else secs
|
2023-08-28 02:43:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
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"
|
2023-10-23 10:46:25 +03:00
|
|
|
return " ".join([result, secs]) if result else secs
|