ANT*_*ONY 3 linux performance x86 perf
perf stat -d ./sample.out输出为:
Performance counter stats for './sample.out':
0.586266 task-clock (msec) # 0.007 CPUs utilized
2 context-switches # 0.003 M/sec
1 cpu-migrations # 0.002 M/sec
116 page-faults # 0.198 M/sec
7,35,790 cycles # 1.255 GHz [81.06%]
<not counted> stalled-cycles-frontend
<not supported> stalled-cycles-backend
<not counted> instructions
<not counted> branches
<not counted> branch-misses
<not supported> L1-dcache-loads:HG
<not counted> L1-dcache-load-misses:HG
<not counted> LLC-loads:HG
<not supported> LLC-load-misses:HG
0.088013919 seconds time elapsed
Run Code Online (Sandbox Code Playgroud)
我读了为什么会出现 .但我甚至得到了基本的指示器,如指令,分支机构等.任何人都可以建议如何让它工作?
有趣的是:
sudo perf stat sleep 3
给出输出:
Performance counter stats for 'sleep 3':
0.598484 task-clock (msec) # 0.000 CPUs utilized
2 context-switches # 0.003 M/sec
0 cpu-migrations # 0.000 K/sec
181 page-faults # 0.302 M/sec
<not counted> cycles
<not counted> stalled-cycles-frontend
<not supported> stalled-cycles-backend
<not counted> instructions
<not counted> branches
<not counted> branch-misses
Run Code Online (Sandbox Code Playgroud)
sudo perf stat -C 1 sleep 3
Performance counter stats for 'CPU(s) 1':
3002.640578 task-clock (msec) # 1.001 CPUs utilized [100.00%]
425 context-switches # 0.142 K/sec [100.00%]
9 cpu-migrations # 0.003 K/sec [100.00%]
5 page-faults # 0.002 K/sec
7,82,97,019 cycles # 0.026 GHz [33.32%]
9,38,21,585 stalled-cycles-frontend # 119.83% frontend cycles idle [33.32%]
<not supported> stalled-cycles-backend
3,09,81,643 instructions # 0.40 insns per cycle
# 3.03 stalled cycles per insn [33.32%]
70,15,390 branches # 2.336 M/sec [33.32%]
6,38,644 branch-misses # 9.10% of all branches [33.32%]
3.001075650 seconds time elapsed
Run Code Online (Sandbox Code Playgroud)
为什么这出乎意料的工作呢?
谢谢
perf stat -d非常短的程序的典型问题不是统计抽样,而是多路复用(方括号中的百分比表示[33%]- 此计数器仅计算约33%的运行时间).
您要求PMU一次监视太多事件,并且perf无法同时在真实硬件(PMU - CPU的性能监视单元)上映射所有必需的计数器.典型的PMU可能具有4或7或8个独立计数器,但如果您启用了某些SMT技术(例如,HT - 超线程),则该数量可以除以2.
当你要求perf计算这么多计数器时(你的perf stat输出中有6个支持的HW事件),它会将它们分成更小的组.当perf_events有机会改变它们时,内核会在某些时间点更改组,例如在任务时钟滴答(~3 ms).
您可以使用较小的事件集将运行拆分为多个 - 每次运行任意数量的SW事件和2-4个HW事件:
perf stat -e task-clock,page-faults,cycles,stalled-cycles-frontend
perf stat -e task-clock,page-faults,cycles,instructions
perf stat -e task-clock,page-faults,branches,branch-misses
perf stat -e task-clock,page-faults,L1-dcache-load-misses:HG,LLC-loads:HG
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1470 次 |
| 最近记录: |