【问题标题】:Meaning of very high Elapsed(wall clock) time and low System time in LinuxLinux中非常高的已用(挂钟)时间和低系统时间的含义
【发布时间】:2016-03-03 07:00:42
【问题描述】:

我有一个 C++ 二进制文件,我正在尝试测量它在最坏情况下的性能。 我用 /usr/bin/time -v

结果是

User time (seconds): 161.07
System time (seconds): 16.64
Percent of CPU this job got: 7%
Elapsed (wall clock) time (h:mm:ss or m:ss): 39:44.46
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 19889808
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 1272786
Voluntary context switches: 233597
Involuntary context switches: 138
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0

我如何解释这个结果,是什么导致这个应用程序花费这么多时间?

无需等待用户输入,主要处理大型文本文件和数据库。

我是从 Linux(OS) 的角度来看的。是不是上下文切换太多(Linux 中的循环调度)导致了这种情况?

【问题讨论】:

  • 它显然在等待什么。最大常驻设置19GB?一百万页错误?每秒超过 500 次。虽然它没有使用磁盘或其他任何东西,但看起来过分了。

标签: c++ linux performance-testing


【解决方案1】:

您可以做的最好的事情是使用诸如 gprof、gperftools、callgrind(valgrind 的一部分)或(我认为最好的)Intel VTune 之类的分析器来运行它。他们可以向您展示代码背后的内容。并且您最好使用调试符号(!= 而不是在没有优化的情况下进行编译)以清楚地了解这一点。否则,您只能对引擎盖下发生的事情进行“最佳猜测”...

正如我所说,我偏向于 VTune,因为它速度快,而且可以显示很多有用的信息。看一个例子:

Vtune example

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-30
    • 1970-01-01
    • 2016-07-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多