go pprof的安装使用

2019-05-24  本文已影响0人  loki528

下载Graphviz 为pprof的输出提供图形化的显示

https://graphviz.gitlab.io/_pages/Download/Download_windows.html

添加dot.exe的路劲到环境变量

D:\Program Files (x86)\Graphviz2.38\bin

在 main 方法中增加

import _ "net/http/pprof"

func main() {

    go func() {

        http.ListenAndServe("localhost:6060", nil)

    }()

然后就可以在浏览器中使用http://localhost:port/debug/pprof/直接看到当前web服务的状态,包括CPU占用情况和内存使用情况等。

参考 https://studygolang.com/articles/7069

https://studygolang.com/articles/14519?fr=sidebar

上一篇 下一篇

猜你喜欢

热点阅读