pyinstrumentPython 代码性能分析库
pyinstrument 是简单易用的 Python 代码性能分析库,用于优化 Python 代码的工具。支持 Python 3.7+,能够分析异步代码,仅需一条命令即可显示具体到函数的耗时,快速指出影响代码性能的地方,帮助提高代码性能,让你的代码快人一步。
# 命令模式
Usage: pyinstrument [options] scriptfile [arg] ...
# 代码片段模式
from pyinstrument import Profiler
profiler = Profiler()
profiler.start()
# 要分析的代码
profiler.stop()
profiler.print()
# 还支持 flask 等 Web 框架
评论
