All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org,
	acme@redhat.com, dsahern@gmail.com, adrian.hunter@intel.com,
	tglx@linutronix.de, namhyung@kernel.org, noelgrandin@gmail.com,
	jolsa@kernel.org, hpa@zytor.com, mingo@kernel.org
Subject: [tip:perf/core] perf script: Align event name properly
Date: Sat, 9 Jan 2016 08:38:01 -0800	[thread overview]
Message-ID: <tip-9cdbc409626b29ab30f06a6393db6763f040f753@git.kernel.org> (raw)
In-Reply-To: <1452158050-28061-9-git-send-email-jolsa@kernel.org>

Commit-ID:  9cdbc409626b29ab30f06a6393db6763f040f753
Gitweb:     http://git.kernel.org/tip/9cdbc409626b29ab30f06a6393db6763f040f753
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 7 Jan 2016 10:14:05 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 8 Jan 2016 12:57:26 -0300

perf script: Align event name properly

Adding code to align event names, so we get aligned output in case of
multiple events with different names.

Before:
  $ perf script
  :13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010
  :13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P:     7f5a5f719f00
  :13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P:     7f5a5f719f00
  :13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810
  :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
  :13757 13757 163918.155264: cpu/mem-snp-hitm/P:           601080
  ...

After:
  $ perf script
  :13757 13757 163918.228831:       cpu/mem-snp-none/P: ffffffff81a841c0
  :13757 13757 163918.228834: cpu/mem-loads,ldlat=30/P:     7f5a5f719f08
  :13757 13757 163918.228837: cpu/mem-loads,ldlat=30/P:     7f5a5f719f08
  :13758 13758 163918.228837:       cpu/mem-snp-none/P: ffff88085f4ad800
  :13758 13758 163918.154093:         cpu/mem-stores/P: ffff88085bb53f28
  :13757 13757 163918.155264:       cpu/mem-snp-hitm/P:           601080
  ...

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Noel Grandin <noelgrandin@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1452158050-28061-9-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 5e2f9d2..c691214 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -617,9 +617,24 @@ struct perf_script {
 	bool			allocated;
 	struct cpu_map		*cpus;
 	struct thread_map	*threads;
+	int			name_width;
 };
 
-static void process_event(struct perf_script *script __maybe_unused, union perf_event *event,
+static int perf_evlist__max_name_len(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel;
+	int max = 0;
+
+	evlist__for_each(evlist, evsel) {
+		int len = strlen(perf_evsel__name(evsel));
+
+		max = MAX(len, max);
+	}
+
+	return max;
+}
+
+static void process_event(struct perf_script *script, union perf_event *event,
 			  struct perf_sample *sample, struct perf_evsel *evsel,
 			  struct addr_location *al)
 {
@@ -636,7 +651,12 @@ static void process_event(struct perf_script *script __maybe_unused, union perf_
 
 	if (PRINT_FIELD(EVNAME)) {
 		const char *evname = perf_evsel__name(evsel);
-		printf("%s: ", evname ? evname : "[unknown]");
+
+		if (!script->name_width)
+			script->name_width = perf_evlist__max_name_len(script->session->evlist);
+
+		printf("%*s: ", script->name_width,
+		       evname ? evname : "[unknown]");
 	}
 
 	if (print_flags)

  reply	other threads:[~2016-01-09 16:38 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07  9:13 [PATCHv2 00/13] perf tools: Various fixes Jiri Olsa
2016-01-07  9:13 ` [PATCH 01/13] perf tools: Remove perf_evlist__(enable|disable)_event functions Jiri Olsa
2016-01-09 16:40   ` [tip:perf/core] perf evlist: Remove perf_evlist__(enable|disable) _event functions tip-bot for Jiri Olsa
2016-01-07  9:13 ` [PATCH 02/13] perf tools: Make perf_evlist__open() open evsels with their cpus and threads (like perf record does) Jiri Olsa
2016-01-09 16:40   ` [tip:perf/core] perf evlist: " tip-bot for Adrian Hunter
2016-01-07  9:14 ` [PATCH 03/13] perf tools: Use find_map function in access_dso_mem Jiri Olsa
2016-01-09 16:41   ` [tip:perf/core] perf unwind: " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 04/13] perf tools libunwind: Check for mmaps also in MAP__VARIABLE tree Jiri Olsa
2016-01-09 16:41   ` [tip:perf/core] perf unwind: " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 05/13] perf tools libdw: " Jiri Olsa
2016-01-09 16:41   ` [tip:perf/core] perf " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 06/13] perf record: Store data mmaps for dwarf unwind Jiri Olsa
2016-01-07 11:12   ` Namhyung Kim
2016-01-07 12:39     ` [PATCHv2 " Jiri Olsa
2016-01-07 13:14       ` Namhyung Kim
2016-01-07 13:30         ` [PATCHv3 " Jiri Olsa
2016-01-07 20:42           ` Arnaldo Carvalho de Melo
2016-01-09 16:42           ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 07/13] perf tools: Do not show trace command if it's not compiled in Jiri Olsa
2016-01-09 16:37   ` [tip:perf/core] perf tools: Do not show trace command if it' s " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 08/13] perf script: Align event name properly Jiri Olsa
2016-01-09 16:38   ` tip-bot for Jiri Olsa [this message]
2016-01-07  9:14 ` [PATCH 09/13] perf tools: Include all tools/lib directory for tags/cscope/TAGS targets Jiri Olsa
2016-01-09 16:38   ` [tip:perf/core] perf tools: Include all tools/ lib " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 10/13] perf tools: Remove list entry from struct sort_entry Jiri Olsa
2016-01-07 11:13   ` Namhyung Kim
2016-01-09 16:38   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 11/13] perf tools: Add overhead/overhead_children keys defaults via string Jiri Olsa
2016-01-07 11:17   ` Namhyung Kim
2016-01-09 16:39   ` [tip:perf/core] perf tools: Add overhead/ overhead_children " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 12/13] perf diff: Use perf_hpp__register_sort_field interface Jiri Olsa
2016-01-07 11:17   ` Namhyung Kim
2016-01-09 16:39   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-01-07  9:14 ` [PATCH 13/13] perf tools: Export a couple of hist functions Jiri Olsa
2016-01-09 16:39   ` [tip:perf/core] perf hists: " 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=tip-9cdbc409626b29ab30f06a6393db6763f040f753@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=noelgrandin@gmail.com \
    --cc=tglx@linutronix.de \
    /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.