Discuss / Python / 作业

作业

Topic source

Junhong1994

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

def metric(fn): @functools.wraps(fn) def wrapper(*args,**kw): start = time.perf_counter() t = fn(*args,**kw) end = time.perf_counter()
print('%s executed in %s ms' % (fn.__name__, (end - start))) return t return wrapper

结果: fast executed in 0.001296294560962212 ms slow executed in 0.12408149386680874 ms


  • 1

Reply