答案代码复制到pycharm,结果时间为0.000000s?
import time
def performance(f):
def fn(*args,**kw):
t1=time.time()
r=f(*args,**kw)
t2=time.time()
print 'call %s() in %fs' % (f.__name__,(t2-t1))
return r
return fn
@performance
def factorial(n):
return reduce(lambda x,y:x*y,range(1,n+1))
print factorial(10)
运行结果:
call factorial() in 0.000000s
3628800
请问time.time()和time.clock()的区别?