gin集成pporf
main.go添加
import _ "net/http/pprof"
gin路由添加
// r is *gin.Engine
pprof.Register(r)
本地電腦鏈接到遠程web服務進行分析
然後本地電腦打開
假設你的goweb程序服務地址是 192.168.2.25:3100
go tool pprof -http=:8080 http://192.168.2.25:3100/debug/pprof/heap
效果圖
就可以看到
確實比 c語言古老的 perf等工具要現代化多了