最近在比较小蟒蛇(Python)和骆驼(Perl)谁跑得快,学到了一些知识,记录在这里!
目录
2.Perl脚本运行时间计算(注意:是在linux终端输入的)
1.Python脚本运行时间计算
①使用time(),这个时间会受其他程序的干扰
from time import time
start=time()
##你的代码
end=time()
print(end-start,"s")
②使用time.perf_counter(),测得时间较上一个更准确
import time
start=time.perf_counter()
##你的代码
end=time.perf_counter()
print(end-start,"s")
参考:https://blog.csdn.net/Augurlee/article/details/107505791
2.Perl脚本运行时间计算(注意:是在linux终端输入的)
time perl filename.pl