【问题标题】:cpuprofile and memprofile in golang testinggolang测试中的cpuprofile和memprofile
【发布时间】:2016-12-30 10:00:05
【问题描述】:

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

类似地 go test -memprofile mem.out 生成了一个 mem.out 文件,这对我来说似乎也没有任何意义。帮帮我。

我已附上这两个文件。

cpu.outmem.out

【问题讨论】:

    标签: testing go memprof


    【解决方案1】:

    使用与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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-25
      • 1970-01-01
      • 2014-07-13
      • 2019-11-02
      • 2013-10-12
      • 2015-08-21
      • 2019-05-28
      • 2015-05-06
      相关资源
      最近更新 更多