假设我有两个执行相同任务的二进制文件 - 它们将复杂数据从一种格式转换为另一种格式。
我会在低优先级的繁忙服务器上运行它们,我真的不在乎一个是否比另一个快 - 我想知道它们中哪一个会降低“CPU影响”来执行相同的任务。 / p>
binary_1:
26879408.172126 task-clock:u (msec) # 0.709 CPUs utilized
0 context-switches:u # 0.000 K/sec
0 cpu-migrations:u # 0.000 K/sec
1142192473 page-faults:u # 0.042 M/sec
81241884199345 cycles:u # 3.022 GHz (83.59%)
65593453047217 stalled-cycles-frontend:u # 80.74% frontend cycles idle (83.59%)
34800591044061 stalled-cycles-backend:u # 42.84% backend cycles idle (67.09%)
98783244945290 instructions:u # 1.22 insn per cycle
# 0.66 stalled cycles per insn (83.64%)
18250463170335 branches:u # 678.976 M/sec (83.60%)
169450790563 branch-misses:u # 0.93% of all branches (83.59%)
37911.679793230 seconds time elapsed
binary_2:
33134123.016486 task-clock:u (msec) # 1.071 CPUs utilized
0 context-switches:u # 0.000 K/sec
0 cpu-migrations:u # 0.000 K/sec
1947142971 page-faults:u # 0.059 M/sec
105227191042973 cycles:u # 3.176 GHz (83.69%)
80721331715962 stalled-cycles-frontend:u # 76.71% frontend cycles idle (83.69%)
46245245856602 stalled-cycles-backend:u # 43.95% backend cycles idle (67.25%)
140459525725760 instructions:u # 1.33 insn per cycle
# 0.57 stalled cycles per insn (83.93%)
9187630340020 branches:u # 277.286 M/sec (83.70%)
112107883833 branch-misses:u # 1.22% of all branches (83.69%)
30949.033426941 seconds time elapsed
如您所见,binary_1执行37911秒,binary_2执行30949秒。
另一方面,binary_2使用了更多的循环和指令。
因为我将在繁忙的服务器上运行它,我认为binary_1对CPU(以及其他任务)的影响较小。我的推理是否正确?