golang 性能測試pprof


植入:
    在main包中 import _ "net/http/pprof"

    在main函數中添加

         go func() {
               log.Println(http.ListenAndServe("0.0.0.0:6060", nil))
         }()

      就這樣兩步就完成了pprof植入

 

分析:

    

    go tool pprof http://localhost:6060/debug/pprof/heap  查看堆棧

    

     top10  

     

 自動彈出網頁展示svg圖,如果
報錯:Failed to execute dot. Is Graphviz installed? Error: exec: "dot": executable file not found in %PATH%
請到http://www.graphviz.org/Download.php下載Graphviz, 並配置到環境變量中

svg圖如下

   

 
        
go tool pprof http://localhost:6060/debug/pprof/profile 查看30秒內CPU的情況
常用命名跟上面一樣, top10、web

想了解更多可以查閱官網
https://golang.org/pkg/net/http/pprof/




 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM