Skip to content

Instantly share code, notes, and snippets.

@akrisanov
Created August 28, 2020 13:31
Show Gist options
  • Save akrisanov/91eea01118f3d2ce58855d15dd2dfbea to your computer and use it in GitHub Desktop.
Save akrisanov/91eea01118f3d2ce58855d15dd2dfbea to your computer and use it in GitHub Desktop.

pprof

$ go test -bench=. -benchmem -cpuprofile=cpu.out -memprofile=mem.out -x .

$ go tool pprof 13_pprof_console.test cpu.out

$ go tool pprof 13_pprof_console.test mem.out
$ go tool pprof -help
$ go tool pprof -http :8090 binary cpu.out

pprof - web profiling

$ wrk -c100 -d2000s -t50 http://127.0.0.1:8080/
$ go tool pprof http://localhost:8080/debug/pprof/profile?seconds=5
$ go tool pprof http://localhost:8080/debug/pprof/goroutines

or

$ go tool pprof -http :8082 \
http://localhost:8081/debug/pprof/profile?seconds=5

$ go tool pprof -http :8082 \
http://localhost:8081/debug/pprof/heap?seconds=5

FlameGraph

go tool pprof

Tracing

https://golang.org/pkg/runtime/trace/

$ wrk -c100 -d2000s -t50 http://127.0.0.1:8080/

$ wget http://localhost:8080/debug/pprof/trace?seconds=5 -o trace.out

$ go tool trace trace?seconds=5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment