python程序运行时间逐行分析
比较了cProfile、profile和line_profiler,感觉还是pyinstrument达到了我想要结果。
from pyinstrument import Profiler
profiler = Profiler(interval=0.0001) # interval表示最小监视的运行时间,默认为0.001
profiler.start()
# 添加测试程序 #
profiler.stop()
profiler.print() # 在命令行中输出
profiler.output_html() # 输出成一个html文件
运行结果:


浙公网安备 33010602011771号