From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
David Ahern <dsahern@gmail.com>, Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 3/3] perf script: Align event name properly
Date: Thu, 26 Nov 2015 14:55:25 +0100 [thread overview]
Message-ID: <1448546125-29245-3-git-send-email-jolsa@kernel.org> (raw)
In-Reply-To: <1448546125-29245-1-git-send-email-jolsa@kernel.org>
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
...
Link: http://lkml.kernel.org/n/tip-hsrwmiogt9menjsg7uaxqvq2@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
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 3c3f8d0e3064..10a96da0ea56 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -594,9 +594,24 @@ struct perf_script {
bool show_task_events;
bool show_mmap_events;
bool show_switch_events;
+ 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)
{
@@ -613,7 +628,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)
--
2.4.3
next prev parent reply other threads:[~2015-11-26 13:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-26 13:55 [PATCH 1/3] perf script: Remove default_scripting_ops Jiri Olsa
2015-11-26 13:55 ` [PATCH 2/3] perf script: Pass perf_script into process_event Jiri Olsa
2015-11-26 16:22 ` Arnaldo Carvalho de Melo
2015-11-26 17:55 ` [PATCHv2 " Jiri Olsa
2015-11-27 7:45 ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-11-26 13:55 ` Jiri Olsa [this message]
2015-11-26 14:25 ` [PATCH 3/3] perf script: Align event name properly David Ahern
2015-11-26 14:30 ` Jiri Olsa
2015-11-26 14:34 ` David Ahern
2015-12-27 11:59 ` Jiri Olsa
2015-11-26 16:33 ` [PATCH 1/3] perf script: Remove default_scripting_ops Arnaldo Carvalho de Melo
2015-11-27 7:43 ` [tip:perf/core] " tip-bot for Jiri Olsa
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=1448546125-29245-3-git-send-email-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=dsahern@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox