mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>,
	David Ahern <dsahern@gmail.com>,
	Stephane Eranian <eranian@google.com>,
	Andi Kleen <andi@firstfloor.org>,
	Pekka Enberg <penberg@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: [RFC/PATCH 2/2] perf report: Add --time-filter option
Date: Wed, 15 May 2013 18:23:59 +0900	[thread overview]
Message-ID: <1368609839-19899-2-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1368609839-19899-1-git-send-email-namhyung@kernel.org>

From: Namhyung Kim <namhyung.kim@lge.com>

The --time-filter option is for limiting samples within a range of
time.  A time range looks like <time1>-<time2> and at most one of them
can be omitted.  This can be useful when analyzing a part of a huge
data only.

Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-report.txt |  6 ++++++
 tools/perf/builtin-report.c              | 33 ++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 7d5f4f38aa52..67544c2d8e69 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -210,6 +210,12 @@ OPTIONS
 	Demangle symbol names to human readable form. It's enabled by default,
 	disable with --no-demangle.
 
+--time-filter::
+	Report samples within a range of time only. A time range can be given
+	like 'time1-time2' and treated as a start time and end time
+	respectively. The time format is like "<sec>.<usec>". Either of time1
+	or time2 can be omitted.
+
 SEE ALSO
 --------
 linkperf:perf-stat[1], linkperf:perf-annotate[1]
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d45bf9b0361d..2cd3f640cc4a 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -52,6 +52,7 @@ struct perf_report {
 	symbol_filter_t		annotate_init;
 	const char		*cpu_list;
 	const char		*symbol_filter_str;
+	u64			time_start, time_end;
 	DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
 };
 
@@ -311,6 +312,12 @@ static int process_sample_event(struct perf_tool *tool,
 	if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap))
 		return 0;
 
+	if (rep->time_start && rep->time_start > sample->time)
+		return 0;
+
+	if (rep->time_end && rep->time_end < sample->time)
+		return 0;
+
 	if (sort__mode == SORT_MODE__BRANCH) {
 		if (perf_report__add_branch_hist_entry(tool, &al, sample,
 						       evsel, machine)) {
@@ -700,6 +707,30 @@ parse_branch_mode(const struct option *opt __maybe_unused,
 	return 0;
 }
 
+static int
+parse_time_filter(const struct option *opt, const char *str,
+		  int unset __maybe_unused)
+{
+	struct perf_report *rep = opt->value;
+	char *sep;
+
+	sep = strchr(str, '-');
+	if (sep == NULL || sep[1] == '\0') {
+		rep->time_start = parse_nsec_time(str);
+		return 0;
+	} else if (sep == str) {
+		rep->time_end = parse_nsec_time(++str);
+		return 0;
+	}
+
+	*sep++ = '\0';
+
+	rep->time_start = parse_nsec_time(str);
+	rep->time_end = parse_nsec_time(sep);
+
+	return 0;
+}
+
 int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 {
 	struct perf_session *session;
@@ -809,6 +840,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
 	OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
 		    "Disable symbol demangling"),
 	OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"),
+	OPT_CALLBACK(0, "time-filter", &report, "time[-time]",
+		    "Only display entries in the time range", parse_time_filter),
 	OPT_END()
 	};
 
-- 
1.7.11.7


  reply	other threads:[~2013-05-15  9:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-15  9:23 [RFC/PATCH 1/2] perf script: " Namhyung Kim
2013-05-15  9:23 ` Namhyung Kim [this message]
2013-05-15 11:51   ` [RFC/PATCH 2/2] perf report: " Stephane Eranian
2013-05-16  0:48     ` Namhyung Kim
2013-05-15 13:56 ` [RFC/PATCH 1/2] perf script: " Andi Kleen
2013-05-16  0:55   ` Namhyung Kim
2013-05-16 13:09   ` Ingo Molnar
2013-05-15 15:16 ` David Ahern
2013-05-16  1:56   ` Namhyung Kim
2013-05-16  2:42     ` David Ahern
2013-05-16  8:50       ` Namhyung Kim
2013-05-16 13:29         ` David Ahern

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=1368609839-19899-2-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=paulus@samba.org \
    --cc=penberg@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

all inboxes | Powered by JetHome®