Profiling benchmark allocations
$ go test -bench . --memprofile mem.prof -test.memprofilerate=1
$ go tool pprof --alloc_space ./<name-of-your-package>.test mem.prof
Profiling benchmark CPU usage
$ go test -bench . --cpuprofile cpu.prof
$ go tool pprof ./<name-of-your-package>.test cpu.prof