stack ?
flat=Cum 函数中没有调用其他函数
flat=0 函数中只有其他函数的调用
输入 list Eat ,查看问题具体在代码的哪一个位置:根据指定的正则表达式查找
(pprof) list Eat Total: 9.03s ROUTINE ======================== github.com/wolfogre/go-pprof-practice/animal/canidae/dog.(*Dog).Eat in H:\go-pprof-practice\animal\canidae\dog\dog.go 0 10ms (flat, cum) 0.11% of Total . . 26: d.Pee() . . 27: d.Run() . . 28: d.Howl() . . 29:} . . 30:func (d *Dog) Eat() { . 10ms 31: log.Println(d.Name(), "eat") . . 32:} . . 33: . . 34:func (d *Dog) Drink() { . . 35: log.Println(d.Name(), "drink") . . 36:} ROUTINE ======================== github.com/wolfogre/go-pprof-practice/animal/felidae/tiger.(*Tiger).Eat in H:\go-pprof-practice\animal\felidae\tiger\tiger.go 8.91s 8.93s (flat, cum) 98.89% of Total . . 26:无效的循环 . . 27:*/ . . 28:func (t *Tiger) Eat() { . . 29: log.Println(t.Name(), "eat") . . 30: loop := 10000000000 8.91s 8.93s 31: for i := 0; i < loop; i++ { . . 32: // do nothing . . 33: } . . 34:} . . 35: . . 36:func (t *Tiger) Drink() { ?
web 调用关系可视化
可以访问 graphviz 官网寻找适合自己操作系统的安装方法
调查内存
go tool pprof http://localhost:6060/debug/pprof/heap
top
(pprof) top Showing nodes accounting for 1.20GB, 100% of 1.20GB total Dropped 4 nodes (cum <= 0.01GB) flat flat% sum% cum cum% 1.20GB 100% 100% 1.20GB 100% github.com/wolfogre/go-pprof-practice/animal/muridae/mouse.(*Mouse).Steal 0 0% 100% 1.20GB 100% github.com/wolfogre/go-pprof-practice/animal/muridae/mouse.(*Mouse).Live 0 0% 100% 1.20GB 100% main.main 0 0% 100% &nb |