[module]_Python性能分析库_Py-Spy

官方地址:https://github.com/benfred/py-spy
码云地址:https://gitee.com/mirrors/Py-Spy

安装:

pip install py-spy

三个子命令

1
record: 记录, 可导出到文件中. 支持svg格式火焰图, 可以点击查看每个函数的运行时间.

py-spy record -o profile.svg --pid 12345
# OR
py-spy record -o profile.svg -- python demo.py

record

2
top: 监控python程序中哪些函数占用时间最多的实时视图.

py-spy top --pid 12345
# OR
py-spy top -- python demo.py

3
dump: 显示每个python线程的当前调用堆栈.

py-spy dump --pid 12345

原文地址:https://www.cnblogs.com/sunqikai/p/13043914.html