perf stat: Fix misleading message when specifying cpu list or system wide
authorDavid Ahern <[email protected]>
Sat, 28 Sep 2013 20:27:58 +0000 (14:27 -0600)
committerArnaldo Carvalho de Melo <[email protected]>
Fri, 11 Oct 2013 15:17:42 +0000 (12:17 -0300)
The "perf stat" tool displays the command run in its summary output
which is misleading when using a cpu list or system wide collection.

Before:

perf stat -a -- sleep 1

 Performance counter stats for 'sleep 1':

16152.670249 task-clock                #   16.132 CPUs utilized
         417 context-switches          #    0.002 M/sec
           7 cpu-migrations            #    0.030 K/sec
...

After:

perf stat -a -- sleep 1

 Performance counter stats for 'system wide':

16206.931120 task-clock                #   16.144 CPUs utilized
         395 context-switches          #    0.002 M/sec
           5 cpu-migrations            #    0.030 K/sec
...

or

perf stat -C1 -- sleep 1

 Performance counter stats for 'CPU(s) 1':

   1001.669257 task-clock                #    1.000 CPUs utilized
         4,264 context-switches          #    0.004 M/sec
             3 cpu-migrations            #    0.003 K/sec
...

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 fb02b53b0e3db2abd728e9df012fb066de4a4993..c8a2662eb57a074adfafe89919a653fe0b33e9c3 100644 (file)
@@ -1229,7 +1229,11 @@ static void print_stat(int argc, const char **argv)
        if (!csv_output) {
                fprintf(output, "\n");
                fprintf(output, " Performance counter stats for ");
-               if (!perf_target__has_task(&target)) {
+               if (target.system_wide)
+                       fprintf(output, "\'system wide");
+               else if (target.cpu_list)
+                       fprintf(output, "\'CPU(s) %s", target.cpu_list);
+               else if (!perf_target__has_task(&target)) {
                        fprintf(output, "\'%s", argv[0]);
                        for (i = 1; i < argc; i++)
                                fprintf(output, " %s", argv[i]);