douningchang3610 2016-12-30 10:00
浏览 659
已采纳

Golang测试中的cpuprofile和memprofile

I tried the command go test -cpuprofile cpu.out on a GO test file and it resulted in a file cpu.out which is full of many 64 bit numbers. It doesn't make any sense to me. What did the command do and what information can get I extract from cpu.out file?

Similarly go test -memprofile mem.out generated a mem.out file which also seems to make no sense to me. Help me out.

I have attached both the files.

cpu.out and mem.out

  • 写回答

1条回答 默认 最新

  • dream752614590 2016-12-30 13:16
    关注

    Use the output profiles in coordination with the go tool e.g.:

    go tool pprof testbin.test cpu.out
    

    I'd recommend some func Benchmark*(b *testing.B) implementations for functionality you're interesting in profiling.

    Once in the tool try top10:

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

    More information: https://blog.golang.org/profiling-go-programs

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!