trace && pprof

Of course, go tool trace can’t solve everything. It’s not appropriate if you want to track down slow functions, or generally find where your program is spending most of its CPU time. For that you should use go tool pprof, which shows the percentage of CPU time spent in each function. go tool trace is better suited at finding out what your program is doing over time, not in aggregate. Also, there are other visualizations offered by go tool trace alongside the “View Trace” link, and these are particularly useful to diagnose contention issues. There’s also no substitute to knowing your program’s performance in theory (with old-fashioned Big-O analysis).

 

当然,go工具追踪并不能解决所有问题。如果您想追踪慢速函数,或者想找出您的程序在哪里花费了大部分的CPU时间,那么它并不合适。为此,你应该使用 go tool pprof,它可以显示每个函数所花费的 CPU 时间的百分比。go tool trace 更适合于找出你的程序在一段时间内的工作情况,而不是总的情况。另外,在 "View Trace "链接旁边,go tool trace还提供了其他可视化的功能,这些功能对于诊断争用问题特别有用。在理论上了解你的程序性能也是无可替代的(用老式的大O分析)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值