获取程序执行时间
def profile(func):
def wrapper(*args, **kwargs):
import time
st_time = time.time()
func(*args, **kwargs)
ed_time = time.time()
print(f"cost {ed_time-st_time} time")
return wrapper
def fib(n):
if n<2:
return 1
return fib(n-1) + fib(n-2)
@profile
def main(n):
fib(n)
if __name__ == '__main__'
main(6)