golang测试中的cpuprofile和memprofile

时间:2016-12-30 10:00:05

标签: testing go memprof

我在 GO测试文件上尝试了 go test -cpuprofile cpu.out 命令,导致文件 cpu.out 充满了许多64位数字。这对我没有任何意义。命令做了什么以及从cpu.out文件中提取了哪些信息?

同样 go test -memprofile mem.out 生成了一个 mem.out 文件,这似乎对我没用。帮助我。

我已经附上了这两个文件。

cpu.outmem.out

1 个答案:

答案 0 :(得分:9)

go tool配合使用输出配置文件,例如:

go tool pprof testbin.test cpu.out

我推荐一些func Benchmark*(b *testing.B)实施功能,以便您在分析时感兴趣。

进入该工具后,请尝试top10

Welcome to pprof!  For help, type 'help'.
(pprof) top10

更多信息:https://blog.golang.org/profiling-go-programs