_ "net/http/pprof"
go func() {
http.ListenAndServe("localhost:6060", nil)
}()
MEM:
# go tool pprof http://localhost:6060/debug/pprof/heap
$ go tool pprof -base pprof.demo2.alloc_objects.alloc_space.inuse_objects.inuse_space.001.pb.gz pprof.demo2.alloc_objects.alloc_space.inuse_objects.inuse_space.002.pb.gz
CPU:
# go tool pprof http://localhost:6060/debug/pprof/profile
# go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30
调试cpu:
(pprof) top --cum
Showing nodes accounting for 20ms, 8.33% of 240ms total
Showing top 10 nodes out of 125
flat flat% sum% cum cum%
0 0% 0% 140ms 58.33% uis-collector/lib.callCollector
0 0% 0% 100ms 41.67% uis-collector/collector.(*OffInstanceTrafficCollector).Collect
0 0% 0% 80ms 33.33% runtime.systemstack
0 0% 0% 60ms 25.00% uis-collector/collector.(*OffInstanceTrafficCollector).collectTrafficData
0 0% 0% 50ms 20.83% runtime.gcBgMarkWorker
0 0% 0% 50ms 20.83% runtime.gcBgMarkWorker.func2
0 0% 0% 50ms 20.83% runtime.gcDrain
0 0% 0% 50ms 20.83% uis-collector/lib.InitVMStat
0 0% 0% 40ms 16.67% encoding/json.Unmarshal
20ms 8.33% 8.33% 40ms 16.67% runtime.scanobject
(pprof)