Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nnguyent/c2d0f8ccb9132122bd982af0be4ab28c to your computer and use it in GitHub Desktop.
Save nnguyent/c2d0f8ccb9132122bd982af0be4ab28c to your computer and use it in GitHub Desktop.
Go cpu and memory profiling benchmarks. #golang #benchmark
go test -run=. -bench=. -cpuprofile=cpu.out -benchmem -memprofile=mem.out -trace=trace.out
go tool pprof -http :8080 cpu.out
go tool pprof -http :8081 mem.out
go tool trace trace.out
go tool pprof $FILENAME.test cpu.out
# (pprof) list <func name>
rm cpu.out mem.out trace.out *.test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment