All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: acme@Kernel.org
Cc: jolsa@Kernel.org, linux-kernel@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 3/4] perf stat: Print topology/time headers with --metric-only
Date: Tue, 24 May 2016 12:52:38 -0700	[thread overview]
Message-ID: <1464119559-17203-3-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1464119559-17203-1-git-send-email-andi@firstfloor.org>

From: Andi Kleen <ak@linux.intel.com>

When --metric-only is enabled there were no headers for the topology
in interval mode.  Also when headers were printed they were
on a separate line.

Before:

$ perf stat  --metric-only  -A -I 1000 -a
     1.001038376       frontend cycles idle insn per cycle       stalled cycles per insn branch-misses of all branches
     1.001038376 CPU0     123.54%               0.23                5.29                    7.61%
     1.001038376 CPU1     137.78%               0.24                5.13                   10.07%
     1.001038376 CPU2      64.48%               0.22                5.50                    6.84%

After:

$ perf stat  --metric-only  -A -I 1000 -a
     1.001111114 CPU0      82.46%               0.32                2.60                    7.64%
     1.001111114 CPU1     126.63%               0.02               42.83                    0.15%
     1.001111114 CPU2     193.54%               0.32                2.59                    6.92%

v2: Move all headers on a single line
Reported-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/builtin-stat.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index dab184d86816..c01fc7100dad 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1316,7 +1316,7 @@ static int aggr_header_lens[] = {
 	[AGGR_GLOBAL] = 0,
 };
 
-static void print_metric_headers(char *prefix)
+static void print_metric_headers(const char *prefix, bool no_indent)
 {
 	struct perf_stat_output_ctx out;
 	struct perf_evsel *counter;
@@ -1327,7 +1327,7 @@ static void print_metric_headers(char *prefix)
 	if (prefix)
 		fprintf(stat_config.output, "%s", prefix);
 
-	if (!csv_output)
+	if (!csv_output && !no_indent)
 		fprintf(stat_config.output, "%*s",
 			aggr_header_lens[stat_config.aggr_mode], "");
 
@@ -1352,28 +1352,40 @@ 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\n", unit_width, "unit");
 			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\n", unit_width, "unit");
 			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\n", unit_width, "unit");
 			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");
 			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");
 		case AGGR_UNSET:
 			break;
 		}
 	}
 
+	if (num_print_interval == 0 && metric_only)
+		print_metric_headers(" ", true);
 	if (++num_print_interval == 25)
 		num_print_interval = 0;
 }
@@ -1442,8 +1454,8 @@ static void print_counters(struct timespec *ts, int argc, const char **argv)
 	if (metric_only) {
 		static int num_print_iv;
 
-		if (num_print_iv == 0)
-			print_metric_headers(prefix);
+		if (num_print_iv == 0 && !interval)
+			print_metric_headers(prefix, false);
 		if (num_print_iv++ == 25)
 			num_print_iv = 0;
 		if (stat_config.aggr_mode == AGGR_GLOBAL && prefix)
-- 
2.5.5

  parent reply	other threads:[~2016-05-24 19:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24 19:52 [PATCH 1/4] perf stat: Basic support for TopDown in perf stat Andi Kleen
2016-05-24 19:52 ` [PATCH 2/4] perf stat: Add computation of TopDown formulas Andi Kleen
2016-06-01 14:50   ` Nilay Vaish
2016-06-01 14:56     ` Andi Kleen
2016-06-02 11:56       ` Nilay Vaish
2016-06-02 14:26         ` Andi Kleen
2016-06-08  8:39   ` [tip:perf/core] " tip-bot for Andi Kleen
2016-05-24 19:52 ` Andi Kleen [this message]
2016-06-08  8:39   ` [tip:perf/core] perf stat: Print topology/time headers with --metric-only tip-bot for Andi Kleen
2016-05-24 19:52 ` [PATCH 4/4] perf stat: Add missing aggregation headers for --metric-only CSV Andi Kleen
2016-06-08  8:40   ` [tip:perf/core] " tip-bot for Andi Kleen
2016-05-30 16:01 ` [PATCH 1/4] perf stat: Basic support for TopDown in perf stat Arnaldo Carvalho de Melo
2016-05-30 16:04   ` Andi Kleen
2016-05-30 16:19     ` Arnaldo Carvalho de Melo
2016-06-06 14:00       ` Arnaldo Carvalho de Melo
2016-06-06 14:11         ` Arnaldo Carvalho de Melo
2016-06-06 14:36           ` Andi Kleen
2016-06-01 14:24 ` Nilay Vaish
2016-06-01 14:31   ` Andi Kleen
2016-06-01 15:24   ` Andi Kleen
2016-06-02 11:52     ` Nilay Vaish
2016-06-08  8:38 ` [tip:perf/core] " tip-bot for Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464119559-17203-3-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=acme@Kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@Kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.