官方地址: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

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.uj5u.com/houduan/140479.html
標籤:Python
下一篇:Python學習2:猜年齡游戲
