def performance(f):
def fn(x):
start = time.time()
r = f(x)
print r
print "call " + f.__name__ + "() in:" + str(time.time() - start)
return fn
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)
def fn(x):
start = time.time()
r = f(x)
print r
print "call " + f.__name__ + "() in:" + str(time.time() - start)
return fn
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)
2015-12-22