Skip to content
gqlxj1987's Blog
Go back

Go new trace features to debug

Edit page

原文链接

old: go test -cpuprofile cpu.prof
new: go1.10beta1 tool pprof -http=localhost:12345 cpu.prof
go test —blockprofile=block.out


< go tool pprof block.out 
Main binary filename not available.
Type: delay
Entering interactive mode (type “help” for commands, “o” for options)
(pprof) top
Showing nodes accounting for 12.65s, 100% of 12.65s total
 flat flat% sum% cum cum%
 12.65s 100% 100% 12.65s 100% <unknown>
< go1.10beta1 tool pprof block.out
(pprof) top
Showing nodes accounting for 12.34s, 100% of 12.34s total
Dropped 31 nodes (cum <= 0.06s)
Showing top 10 nodes out of 32
      flat  flat%   sum%        cum   cum%
     4.21s 34.09% 34.09%      4.21s 34.09%  runtime.chanrecv1
     4.13s 33.46% 67.55%      4.13s 33.46%  runtime.selectgo
     4.01s 32.45%   100%      4.01s 32.45%  sync.(*WaitGroup).Wait
         0     0%   100%      4.01s 32.45%  github.com/cep21/trace-110.TestServer
         0     0%   100%      4.01s 32.45%  github.com/cep21/trace-110.startServer
         0     0%   100%         4s 32.40%  github.com/cep21/trace-110.takeIO

trace

go test -trace trace.out

go1.10beta1 tool trace trace.out

Edit page
Share this post on:

Previous Post
Pysnooper
Next Post
Modern Server-side Stack