在 Linux 中,非常高的经过(挂钟)时间和低系统时间的含义
Meaning of very high Elapsed(wall clock) time and low System time in Linux
我有一个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 中的循环调度)导致了这种情况?
你能做的最好的事情是使用像gprof,gperftools,callgrind(valgrind的一部分)或(在我看来最好的)Intel VTune这样的分析器运行它。他们可以向您展示代码背后的内容。而且您最好拥有调试符号(!=而不是在没有优化的情况下进行编译)来清楚地了解这一点。否则,你可以对引擎盖下发生的事情有"最佳猜测"......
正如我所说,我偏向于 VTune,因为它速度很快,并且显示了很多有用的信息。看这里的例子:
Vtune 示例
相关文章:
- c++ 11 如何获取系统时间?
- 如何使用跨平台代码在C++中设置系统时间?
- 如何使用 CTIME/Chrono Libarey 将开始时间与系统时钟进行比较
- 将系统时间与变量进行比较 - C++
- 即使在多任务处理时,添加用户时间 + 系统时间(来自 shell 的时间命令)是否是一种可靠的措施?
- 系统时间从何而来?
- 对于同一任务,线程的等待时间在 0 到 30000 微秒之间系统地切换
- 测量 std::系统的实际执行时间(以 C++ 为单位)
- Qthread ::更改系统时间时睡眠不正常
- 如何在跨平台C++中以毫秒为单位获得系统启动/启动时间(它应该在Windows / IOS / Android / MA
- 查找系统调用需要多长时间的可能方法
- 在C++的主逻辑中接收真实/用户/系统时间
- 为什么在获取系统时间时在此处使用“atomic_signal_fence”
- 使用rdtsc计算系统时间
- 用C++设置windows系统时间
- 如何使用套接字编程获取系统日期和时间
- 最佳C 11测量嵌入式系统代码执行时间的方法
- 具有较低系统时间的C++时序方法
- 不取决于系统时间的时间
- 我如何在C 的毫秒内获得系统的时间