2

When the perf stat command is used, many default events are measured. For example, when I run perf stat ls, I obtain the following output:

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

Now, let's suppose I also want to measure the cache-references and cache-misses events. If I run perf stat -e cache-references,cache-misses, the output is:

 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

Is there a way to add events with the -e flag, but also keep the default events shown when not using -e (without having to list all of them explicitly in the command) ?

jaja360
  • 45
  • 1
  • 5
  • 1
    You *can* of course just copy/paste those event names with commas. That's what I usually do, like `perf stat --all-user -etask-clock,context-switches,cpu-migrations,page-faults,cycles,branches,instructions,uops_issued.any,uops_retired.retire_slots,uops_executed.thread` since they're not magic. But yeah it would be nice to be able to add to the defaults like `-d` does instead of replacing, good question. – Peter Cordes Oct 24 '21 at 21:14
  • duplicate of [How to add specific event counters to Perf whilst keeping the default output/events?](https://stackoverflow.com/q/73396582) - I decided to answer when this got re-asked. – Peter Cordes Aug 19 '22 at 09:53

0 Answers0