How Pycharm displays the running time of program completion

Solve the display of the running time of the program in Pycharm

1. Import the time library and set the start time before the entire program runs

import time
start = time.clock()
# 在此导入time库,并在开头设置开始时间

2. Set the program completion time at the end of the entire program operation

end = time.clock()
# 在程序运行结束的位置添加结束时间

3. Print the end time minus the start time to show the running time

print("运行耗时", end-start)
# 再将其进行打印,即可显示出程序完成的运行耗时

After setting, the code running time-consuming display
Insert picture description here

Guess you like

Origin blog.csdn.net/JasonZ227/article/details/109549418