All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@kernel.org>, Paul Mackerras <paulus@samba.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	Namhyung Kim <namhyung@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>, Andi Kleen <andi@firstfloor.org>,
	Don Zickus <dzickus@rehdat.com>
Subject: [PATCH 16/20] perf hists: Reset width of output fields with header length
Date: Mon, 19 May 2014 15:25:58 +0900	[thread overview]
Message-ID: <1400480762-22852-17-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1400480762-22852-1-git-send-email-namhyung@kernel.org>

Some fields missed to set default column length so it broke align in
--stdio output.  Add perf_hpp__reset_width() to set it to a sane
default value.

Note that this change will ignore -w/--column-widths option for now.

Before:
  $ perf report -F cpu,comm,overhead --stdio
  ...
  # CPU          Command  Overhead
  #   ...............  ........
  #
    0          firefox     2.65%
    0      kworker/0:0     1.45%
    0          swapper     5.52%
    0         synergys     0.92%
    1          firefox     4.54%

After:
  # CPU          Command  Overhead
  # ...  ...............  ........
  #
      0          firefox     2.65%
      0      kworker/0:0     1.45%
      0          swapper     5.52%
      0         synergys     0.92%
      1          firefox     4.54%

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/stdio/hist.c | 21 +++------------------
 tools/perf/util/hist.h     |  1 +
 tools/perf/util/sort.c     | 12 ++++++++++++
 3 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index e3fdf4e869fc..cfcd3f6fd1c5 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -369,12 +369,10 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 		      int max_cols, float min_pcnt, FILE *fp)
 {
 	struct perf_hpp_fmt *fmt;
-	struct sort_entry *se;
 	struct rb_node *nd;
 	size_t ret = 0;
 	unsigned int width;
 	const char *sep = symbol_conf.field_sep;
-	const char *col_width = symbol_conf.col_width_list_str;
 	int nr_rows = 0;
 	char bf[96];
 	struct perf_hpp dummy_hpp = {
@@ -387,22 +385,9 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
 
 	init_rem_hits();
 
-	list_for_each_entry(se, &hist_entry__sort_list, list) {
-		if (se->elide)
-			continue;
-		width = strlen(se->se_header);
-		if (symbol_conf.col_width_list_str) {
-			if (col_width) {
-				hists__set_col_len(hists, se->se_width_idx,
-						   atoi(col_width));
-				col_width = strchr(col_width, ',');
-				if (col_width)
-					++col_width;
-			}
-		}
-		if (!hists__new_col_len(hists, se->se_width_idx, width))
-			width = hists__col_len(hists, se->se_width_idx);
-	}
+
+	perf_hpp__for_each_format(fmt)
+		perf_hpp__reset_width(fmt, hists);
 
 	if (!show_header)
 		goto print_entries;
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index f67feb432a44..034db761630e 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -202,6 +202,7 @@ void perf_hpp__append_sort_keys(void);
 bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
 bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
 bool perf_hpp__should_skip(struct perf_hpp_fmt *format);
+void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists);
 
 typedef u64 (*hpp_field_fn)(struct hist_entry *he);
 typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 0fe7cbe47ea3..9bee7288465f 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1089,6 +1089,18 @@ bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
 	return hse_a->se == hse_b->se;
 }
 
+void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
+{
+	struct hpp_sort_entry *hse;
+
+	if (!perf_hpp__is_sort_entry(fmt))
+		return;
+
+	hse = container_of(fmt, struct hpp_sort_entry, hpp);
+	hists__new_col_len(hists, hse->se->se_width_idx,
+			   strlen(hse->se->se_header));
+}
+
 static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
 			      struct perf_evsel *evsel)
 {
-- 
1.9.2


  parent reply	other threads:[~2014-05-19  6:30 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-19  6:25 [PATCHSET 00/20] perf report: Add -F option for specifying output fields (v6) Namhyung Kim
2014-05-19  6:25 ` [PATCH 01/20] perf tools: Add ->cmp(), ->collapse() and ->sort() to perf_hpp_fmt Namhyung Kim
2014-05-22 12:20   ` [tip:perf/core] perf tools: Add ->cmp(), ->collapse() and ->sort( ) " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 02/20] perf tools: Convert sort entries to hpp formats Namhyung Kim
2014-05-22 12:20   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 03/20] perf tools: Use hpp formats to sort hist entries Namhyung Kim
2014-05-22 12:20   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 04/20] perf tools: Support event grouping in hpp ->sort() Namhyung Kim
2014-05-22 12:21   ` [tip:perf/core] perf tools: Support event grouping in hpp ->sort( ) tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 05/20] perf tools: Use hpp formats to sort final output Namhyung Kim
2014-05-22 12:21   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 06/20] perf tools: Consolidate output field handling to hpp format routines Namhyung Kim
2014-05-19 13:12   ` Jiri Olsa
2014-05-19 13:54     ` Namhyung Kim
2014-05-20  2:22       ` Namhyung Kim
2014-05-20  7:45         ` Jiri Olsa
2014-05-19  6:25 ` [PATCH 07/20] perf ui: Get rid of callback from __hpp__fmt() Namhyung Kim
2014-05-22 12:21   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 08/20] perf tools: Allow hpp fields to be sort keys Namhyung Kim
2014-05-22 12:21   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 09/20] perf tools: Consolidate management of default sort orders Namhyung Kim
2014-05-22 12:22   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 10/20] perf tools: Call perf_hpp__init() before setting up GUI browsers Namhyung Kim
2014-05-22 12:22   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 11/20] perf report: Add -F option to specify output fields Namhyung Kim
2014-05-22 12:22   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 12/20] perf tools: Add ->sort() member to struct sort_entry Namhyung Kim
2014-05-22 12:22   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 13/20] perf report/tui: Fix a bug when --fields/sort is given Namhyung Kim
2014-05-22 12:22   ` [tip:perf/core] perf report/tui: Fix a bug when --fields/ sort " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 14/20] perf top: Add --fields option to specify output fields Namhyung Kim
2014-05-22 12:23   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 15/20] perf tools: Skip elided sort entries Namhyung Kim
2014-05-22 12:23   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:25 ` Namhyung Kim [this message]
2014-05-22 12:23   ` [tip:perf/core] perf hists: Reset width of output fields with header length tip-bot for Namhyung Kim
2014-05-19  6:25 ` [PATCH 17/20] perf tools: Get rid of obsolete hist_entry__sort_list Namhyung Kim
2014-05-22 12:23   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:26 ` [PATCH 18/20] perf tools: Introduce reset_output_field() Namhyung Kim
2014-05-22 12:23   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:26 ` [PATCH 19/20] perf tests: Factor out print_hists_*() Namhyung Kim
2014-05-22 12:23   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-05-19  6:26 ` [PATCH 20/20] perf tests: Add a testcase for histogram output sorting Namhyung Kim
2014-05-22 12:24   ` [tip:perf/core] " tip-bot for Namhyung Kim

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=1400480762-22852-17-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=dzickus@rehdat.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=paulus@samba.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.