首页 > 解决方案 > 使用带有自定义事件的`perf stat`时如何保留默认事件

问题描述

使用该perf stat命令时,会测量许多默认事件。例如,当我运行时perf stat ls,我获得以下输出:

Performance counter stats for 'ls':

              0,55 msec task-clock                #    0,598 CPUs utilized
                 0      context-switches          #    0,000 /sec
                 0      cpu-migrations            #    0,000 /sec
                99      page-faults               #  179,071 K/sec
         2 324 694      cycles                    #    4,205 GHz
         1 851 372      instructions              #    0,80  insn per cycle
           357 918      branches                  #  647,403 M/sec
            12 897      branch-misses             #    3,60% of all branches

       0,000923884 seconds time elapsed

       0,000993000 seconds user
       0,000000000 seconds sys

现在,假设我想测量cache-referencescache-misses事件。如果我运行perf stat -e cache-references,cache-misses,输出是:

 Performance counter stats for 'ls':

           101 148      cache-references
            34 261      cache-misses              #   33,872 % of all cache refs

       0,000973384 seconds time elapsed

       0,001014000 seconds user
       0,000000000 seconds sys

有没有办法使用-e标志添加事件,但也保留不使用时显示的默认事件-e(无需在命令中明确列出所有事件)?

标签: linuxperf

解决方案


推荐阅读