PHP
·
发表于 5年以前
·
阅读量:8286
def decorator_timer(foo):
def wrapper(*arg, **karg):
t1 = time.time()
result = foo(*arg, **karg)
t2 = time.time()
print(pre+"time:", t2 - t1)
return result
return wrapper
@decorator_timer("@_@")
def my_power(a, b):
return a**b
print(my_power(2,3))
#输出:
#time: 0.0
#5