From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754968AbcETOaM (ORCPT ); Fri, 20 May 2016 10:30:12 -0400 Received: from mga09.intel.com ([134.134.136.24]:18775 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995AbcETOaL (ORCPT ); Fri, 20 May 2016 10:30:11 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,339,1459839600"; d="scan'208";a="706303872" From: Andi Kleen To: acme@kernel.org Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH] perf stat: Print topology/time headers with --metric-only Date: Fri, 20 May 2016 07:29:59 -0700 Message-Id: <1463754599-30786-1-git-send-email-andi@firstfloor.org> X-Mailer: git-send-email 2.5.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen When --metric-only is enabled there were no headers for the topology in interval mode. Fix this here. Before $ perf stat --metric-only -e cycles,instructions -a -I 1000 1.000554967 insn per cycle stalled cycles per insn 1.000554967 0.27 2.000862000 0.24 3.001354948 0.25 After $ perf stat --metric-only -e cycles,instructions -a -I 1000 1.000554967 insn per cycle stalled cycles per insn 1.000554967 0.27 2.000862000 0.24 3.001354948 0.25 Reported-by: Jiri Olsa Signed-off-by: Andi Kleen --- tools/perf/builtin-stat.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 7c5c50b61b28..74d0849d728e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1347,23 +1347,38 @@ static void print_interval(char *prefix, struct timespec *ts) sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep); - if (num_print_interval == 0 && !csv_output && !metric_only) { + if (num_print_interval == 0 && !csv_output) { switch (stat_config.aggr_mode) { case AGGR_SOCKET: - fprintf(output, "# time socket cpus counts %*s events\n", unit_width, "unit"); + fprintf(output, "# time socket cpus"); + if (!metric_only) + fprintf(output, " counts %*s events", unit_width, "unit"); + fputc('\n', output); break; case AGGR_CORE: - fprintf(output, "# time core cpus counts %*s events\n", unit_width, "unit"); + fprintf(output, "# time core cpus"); + if (!metric_only) + fprintf(output, " counts %*s events", unit_width, "unit"); + fputc('\n', output); break; case AGGR_NONE: - fprintf(output, "# time CPU counts %*s events\n", unit_width, "unit"); + fprintf(output, "# time CPU"); + if (!metric_only) + fprintf(output, " counts %*s events", unit_width, "unit"); + fputc('\n', output); break; case AGGR_THREAD: - fprintf(output, "# time comm-pid counts %*s events\n", unit_width, "unit"); + fprintf(output, "# time comm-pid"); + if (!metric_only) + fprintf(output, " counts %*s events\n", unit_width, "unit"); + fputc('\n', output); break; case AGGR_GLOBAL: default: - fprintf(output, "# time counts %*s events\n", unit_width, "unit"); + fprintf(output, "# time"); + if (!metric_only) + fprintf(output, " counts %*s events\n", unit_width, "unit"); + fputc('\n', output); case AGGR_UNSET: break; } -- 2.5.5