Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1404701

[PATCH 2/2] perf stat: Add missing aggregation headers for --metric-only CSV

From Andi Kleen <andi@firstfloor.org>
Newsgroups linux.kernel
Subject [PATCH 2/2] perf stat: Add missing aggregation headers for --metric-only CSV
Date 2016-05-20 22:00 +0200
Message-ID <rAYKu-1Ao-9@gated-at.bofh.it> (permalink)
References <rAYKu-1Ao-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

When in CSV mode --metric-only outputs an header, unlike the other
modes. Previously it did not properly print headers for the
aggregation columns, so the headers were actually shifted against
the real values.

Fix this here by outputting the correct headers for CSV.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/builtin-stat.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 790eeea335cc..5d295da0e41c 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1311,6 +1311,14 @@ static int aggr_header_lens[] = {
 	[AGGR_GLOBAL] = 0,
 };
 
+static const char *aggr_header_csv[] = {
+	[AGGR_CORE] = "core,cpus,",
+	[AGGR_SOCKET] = "socket,cpus",
+	[AGGR_NONE] = "cpu,",
+	[AGGR_THREAD] = "comm-pid,",
+	[AGGR_GLOBAL] = ""
+};
+
 static void print_metric_headers(const char *prefix, bool no_indent)
 {
 	struct perf_stat_output_ctx out;
@@ -1325,6 +1333,12 @@ static void print_metric_headers(const char *prefix, bool no_indent)
 	if (!csv_output && !no_indent)
 		fprintf(stat_config.output, "%*s",
 			aggr_header_lens[stat_config.aggr_mode], "");
+	if (csv_output) {
+		if (stat_config.interval)
+			fputs("time,", stat_config.output);
+		fputs(aggr_header_csv[stat_config.aggr_mode],
+			stat_config.output);
+	}
 
 	/* Print metrics headers only */
 	evlist__for_each(evsel_list, counter) {
-- 
2.5.5

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 2/2] perf stat: Add missing aggregation headers for --metric-only CSV Andi Kleen <andi@firstfloor.org> - 2016-05-20 22:00 +0200
  Re: [PATCH 2/2] perf stat: Add missing aggregation headers for  --metric-only CSV Jiri Olsa <jolsa@redhat.com> - 2016-05-21 13:20 +0200

csiph-web