https://pyinstrument.readthedocs.io/en/latest/guide.html
这是一个 python 性能分析工具.
大致有两种使用方式:
- 命令行直接运行脚本
pyinstrument script.py
- 嵌入到项目中
- 简单包裹代码块
from pyinstrument import Profiler | |
profiler = Profiler() | |
profiler.start() | |
# code you want to profile | |
profiler.stop() | |
profiler.print() |
- 作为中间件嵌入到
django
、flask
、fastapi
、falcon
中使用