[04/11] perf stat: Increase metric length to align outputs

Message ID 20221112032244.1077370-5-namhyung@kernel.org
State New
Headers
Series perf stat: Cleanup perf stat output display (v2) |

Commit Message

Namhyung Kim Nov. 12, 2022, 3:22 a.m. UTC
  When perf stat is called with very detailed events, the output doesn't
align well like below:

  $ sudo perf stat -a -ddd sleep 1

   Performance counter stats for 'system wide':

          8,020.23 msec cpu-clock                        #    7.997 CPUs utilized
             3,970      context-switches                 #  494.998 /sec
               169      cpu-migrations                   #   21.072 /sec
               586      page-faults                      #   73.065 /sec
       649,568,060      cycles                           #    0.081 GHz                      (30.42%)
       304,044,345      instructions                     #    0.47  insn per cycle           (38.40%)
        60,313,022      branches                         #    7.520 M/sec                    (38.89%)
         2,766,919      branch-misses                    #    4.59% of all branches          (39.26%)
        74,422,951      L1-dcache-loads                  #    9.279 M/sec                    (39.39%)
         8,025,568      L1-dcache-load-misses            #   10.78% of all L1-dcache accesses  (39.22%)
         3,314,995      LLC-loads                        #  413.329 K/sec                    (30.83%)
         1,225,619      LLC-load-misses                  #   36.97% of all LL-cache accesses  (30.45%)
   <not supported>      L1-icache-loads
        20,420,493      L1-icache-load-misses            #    0.00% of all L1-icache accesses  (30.29%)
        58,017,947      dTLB-loads                       #    7.234 M/sec                    (30.37%)
           704,677      dTLB-load-misses                 #    1.21% of all dTLB cache accesses  (30.27%)
           234,225      iTLB-loads                       #   29.204 K/sec                    (30.29%)
           417,166      iTLB-load-misses                 #  178.10% of all iTLB cache accesses  (30.32%)
   <not supported>      L1-dcache-prefetches
   <not supported>      L1-dcache-prefetch-misses

       1.002947355 seconds time elapsed

Increase the METRIC_LEN by 3 so that it can align properly.

  $ sudo ./perf stat -a -ddd true

   Performance counter stats for 'system wide':

              233.70 msec cpu-clock                        #   11.714 CPUs utilized
                 320      context-switches                 #    1.369 K/sec
                  31      cpu-migrations                   #  132.648 /sec
                 482      page-faults                      #    2.062 K/sec
          38,414,140      cycles                           #    0.164 GHz                         (6.65%)
          13,656,335      instructions                     #    0.36  insn per cycle              (20.31%)
           3,594,871      branches                         #   15.382 M/sec                       (34.06%)
             124,071      branch-misses                    #    3.45% of all branches             (47.74%)
          14,016,847      L1-dcache-loads                  #   59.977 M/sec                       (61.42%)
             789,534      L1-dcache-load-misses            #    5.63% of all L1-dcache accesses   (65.98%)
             315,353      LLC-loads                        #    1.349 M/sec                       (47.13%)
             171,244      LLC-load-misses                  #   54.30% of all LL-cache accesses    (41.98%)
     <not supported>      L1-icache-loads
           2,591,299      L1-icache-load-misses            #    0.00% of all L1-icache accesses   (36.10%)
          60,421,987      dTLB-loads                       #  258.543 M/sec                       (27.47%)
             123,843      dTLB-load-misses                 #    0.20% of all dTLB cache accesses  (18.88%)
              38,289      iTLB-loads                       #  163.837 K/sec                       (10.34%)
              21,631      iTLB-load-misses                 #   56.49% of all iTLB cache accesses  (2.53%)
     <not supported>      L1-dcache-prefetches
     <not supported>      L1-dcache-prefetch-misses

Acked-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/stat-display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index 96ad0c71adc2..3ddc159df4b2 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -218,7 +218,7 @@  struct outstate {
 	struct evsel *evsel;
 };
 
-#define METRIC_LEN  35
+#define METRIC_LEN  38
 
 static void new_line_std(struct perf_stat_config *config __maybe_unused,
 			 void *ctx)