Discuss / Python / 交作业

交作业

Topic source

Mr.Wayne

#1 Created at ... [Delete] [Delete and Lock User]

def metric(fn):

    @functools.wraps(fn)

    def wrapper(*args, **kwargs):

        start = time.time()

        result = fn(*args, **kwargs)

        end = time.time()

        print(f'{fn.__name__} executed in {(end - start)*1000:.2f} ms')

        return result

    return wrapper


  • 1

Reply