import time def time_value(dec): def wrapper(*args,**kwargs): start_time = time.time() get_str = dec(*args,**kwargs) end_time = time.time() print("函数运行共耗时:",end_time-start_time) return get_str return wrapper @time_value def test(): i = 0 while i < 10000: i += 1 return i print(test())
运行
函数运行共耗时: 0.0006766319274902344 10000
时间: 2024-11-02 23:27:44