最后输出时间显示为0,但是同样通过了,究竟这样对不对
import time
def performance(f):
def fn(*args, **kw):
t1 = time.time()
t2 = time.time()
print 'call %s() in %fs' % (f.__name__, (t2 - t1))
return f(*args, **kw)
return fn
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)