当我使用 Linux 的实用程序测量 Go 程序的运行时间时time
,我得到以下输出:
real 1m9.177s
user 7m1.788s
sys 0m39.016s
当我在 Go 的 pprof CPU 分析器中查看相同程序执行的输出时,我得到以下输出:
Entering interactive mode (type "help" for commands)
(pprof) top
143.32s of 176s total (81.43%)
pprof 从哪里得到这个 176 的数字?它既不是时钟时间也不是 CPU 时间。我正在运行这个程序,GOMAXPROCS
设置为 8,我觉得这与它有关。pprof 究竟如何测量运行时间,为什么它与 linux 的不同time
?