perf stat: Add units to nanosec-based counters
authorDavid Ahern <[email protected]>
Sat, 28 Sep 2013 20:28:00 +0000 (14:28 -0600)
committerArnaldo Carvalho de Melo <[email protected]>
Fri, 11 Oct 2013 15:17:46 +0000 (12:17 -0300)
Ingo pointed out that the task-clock counter should have the units
explicitly stated since it is not a counter.

Before:

perf stat -a -- sleep 1

 Performance counter stats for 'sleep 1':

      16186.874834 task-clock          #   16.154 CPUs utilized
...

After:

perf stat -a -- sleep 1

 Performance counter stats for 'system wide':

      16146.402138 task-clock (msec)   #   16.125 CPUs utilized
...

Reported-by: Ingo Molnar <[email protected]>
Signed-off-by: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/builtin-stat.c

index 2178e6636f71d7b3c9f12f05d1fdd93de81480d8..1a9c95d270aa2326f45ee0d2c036df10601f48a9 100644 (file)
@@ -706,10 +706,13 @@ static void nsec_printout(int cpu, int nr, struct perf_evsel *evsel, double avg)
 {
        double msecs = avg / 1e6;
        const char *fmt = csv_output ? "%.6f%s%s" : "%18.6f%s%-25s";
+       char name[25];
 
        aggr_printout(evsel, cpu, nr);
 
-       fprintf(output, fmt, msecs, csv_sep, perf_evsel__name(evsel));
+       scnprintf(name, sizeof(name), "%s%s",
+                 perf_evsel__name(evsel), csv_output ? "" : " (msec)");
+       fprintf(output, fmt, msecs, csv_sep, name);
 
        if (evsel->cgrp)
                fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);