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分析)。