Python程序运行时间查看方法

time包查看程序运行时间

1
2
3
4
5
6
7
import time

start_time = time.time() # 记录程序开始运行时间
for i in range(10000000):
pass
end_time = time.time() # 记录程序结束运行时间
print('cost %f s' % (end_time - start_time))

输出

1
>>> cost 0.179781 s

Python程序运行时间查看方法
https://blog.lfd.world/2023/05/30/python-cheng-xu-yun-xing-shi-jian-cha-kan-fang-fa/
作者
培根请加蛋
发布于
2023年5月30日
许可协议