aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-diff.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-10-05 10:44:40 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-10-05 13:05:14 -0400
commita06d143e7cfaa10626f3ad0127a9b9169f900add (patch)
treee993446aad3aa8d21b676c5e8099fc33f0078a5c /tools/perf/builtin-diff.c
parentf15eb531d351163f1ea697c2dd8f15b66b01d289 (diff)
perf diff: Add -b option for perf diff to display paired entries only
Adding -b option to perf diff command to display only entries with match in the baseline. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1349448287-18919-2-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-diff.c')
-rw-r--r--tools/perf/builtin-diff.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index a0b531c14b97..1063c31e507c 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -24,6 +24,7 @@ static char const *input_old = "perf.data.old",
24static char diff__default_sort_order[] = "dso,symbol"; 24static char diff__default_sort_order[] = "dso,symbol";
25static bool force; 25static bool force;
26static bool show_displacement; 26static bool show_displacement;
27static bool show_baseline_only;
27 28
28static int hists__add_entry(struct hists *self, 29static int hists__add_entry(struct hists *self,
29 struct addr_location *al, u64 period) 30 struct addr_location *al, u64 period)
@@ -172,6 +173,31 @@ static void perf_evlist__resort_hists(struct perf_evlist *evlist, bool name)
172 } 173 }
173} 174}
174 175
176static void hists__baseline_only(struct hists *hists)
177{
178 struct rb_node *next = rb_first(&hists->entries);
179
180 while (next != NULL) {
181 struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node);
182
183 next = rb_next(&he->rb_node);
184 if (!he->pair) {
185 rb_erase(&he->rb_node, &hists->entries);
186 hist_entry__free(he);
187 }
188 }
189}
190
191static void hists__process(struct hists *old, struct hists *new)
192{
193 hists__match(old, new);
194
195 if (show_baseline_only)
196 hists__baseline_only(new);
197
198 hists__fprintf(new, true, 0, 0, stdout);
199}
200
175static int __cmd_diff(void) 201static int __cmd_diff(void)
176{ 202{
177 int ret, i; 203 int ret, i;
@@ -213,8 +239,7 @@ static int __cmd_diff(void)
213 239
214 first = false; 240 first = false;
215 241
216 hists__match(&evsel_old->hists, &evsel->hists); 242 hists__process(&evsel_old->hists, &evsel->hists);
217 hists__fprintf(&evsel->hists, true, 0, 0, stdout);
218 } 243 }
219 244
220out_delete: 245out_delete:
@@ -235,6 +260,8 @@ static const struct option options[] = {
235 "be more verbose (show symbol address, etc)"), 260 "be more verbose (show symbol address, etc)"),
236 OPT_BOOLEAN('M', "displacement", &show_displacement, 261 OPT_BOOLEAN('M', "displacement", &show_displacement,
237 "Show position displacement relative to baseline"), 262 "Show position displacement relative to baseline"),
263 OPT_BOOLEAN('b', "baseline-only", &show_baseline_only,
264 "Show only items with match in baseline"),
238 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 265 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
239 "dump raw trace in ASCII"), 266 "dump raw trace in ASCII"),
240 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), 267 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),