XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
UTF-8
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"
    return " ".join([result, secs]) if result else 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"
    return " ".join([result, secs]) if result else secs