eastany / eastany.github.com

我的博客
4 stars 3 forks source link

golang pprof #30

Open eastany opened 9 years ago

eastany commented 9 years ago
import _ "net/http/pprof"

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

访问 http://127.0.0.1:6060/debug/pprof/ 会有基本的一些数据 再执行 go tool pprof http://localhost:6060/debug/pprof/profile 会进入30s的采样 随后(pprof):web 即可生成调用消耗的svg图 top10

PS:生成svg图需要安装graphviz

eastany commented 8 years ago

go tool pprof --alloc_space http://localhost:6060/debug/pprof/heap

eastany commented 8 years ago

http://localhost:6060/debug/pprof/heap?debug=1