Discuss / Python / 练习题,将执行时间保留了8位小数。

练习题,将执行时间保留了8位小数。

Topic source

coLBooy

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

import time

def metric(fn):

    def wrapper(*args,**kw):

        t1=time.time()

        result=fn(*args,**kw)

        t2=time.time()

        print('%s executed in %.8f ms' % (fn.__name__, t2-t1))

        return result

    return wrapper


  • 1

Reply