diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-11-08 15:54:33 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-11-08 15:57:37 -0500 |
commit | 95529be47855be6350dfd0b9cd09ea863ca7421f (patch) | |
tree | b68e3cdd61af81390a92523efc53967c4a7a4df8 /tools/perf/builtin-diff.c | |
parent | b821c7325354c589ccc9611cf9e6b0d7490ed6a6 (diff) |
perf diff: Move hists__match to the hists lib
Its not 'diff' specific and will be useful for other use cases, like
bucketizing multiple events in a single session.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-o35urjgxfxxm70aw1wa81s4w@git.kernel.org
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.c | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 8a9db38e562f..e99fb3bc1c2d 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -334,39 +334,6 @@ static void hists__name_resort(struct hists *self, bool sort) | |||
334 | self->entries = tmp; | 334 | self->entries = tmp; |
335 | } | 335 | } |
336 | 336 | ||
337 | static struct hist_entry *hists__find_entry(struct hists *self, | ||
338 | struct hist_entry *he) | ||
339 | { | ||
340 | struct rb_node *n = self->entries.rb_node; | ||
341 | |||
342 | while (n) { | ||
343 | struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node); | ||
344 | int64_t cmp = hist_entry__cmp(he, iter); | ||
345 | |||
346 | if (cmp < 0) | ||
347 | n = n->rb_left; | ||
348 | else if (cmp > 0) | ||
349 | n = n->rb_right; | ||
350 | else | ||
351 | return iter; | ||
352 | } | ||
353 | |||
354 | return NULL; | ||
355 | } | ||
356 | |||
357 | static void hists__match(struct hists *older, struct hists *newer) | ||
358 | { | ||
359 | struct rb_node *nd; | ||
360 | |||
361 | for (nd = rb_first(&newer->entries); nd; nd = rb_next(nd)) { | ||
362 | struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node), | ||
363 | *pair = hists__find_entry(older, pos); | ||
364 | |||
365 | if (pair) | ||
366 | hist__entry_add_pair(pos, pair); | ||
367 | } | ||
368 | } | ||
369 | |||
370 | static struct perf_evsel *evsel_match(struct perf_evsel *evsel, | 337 | static struct perf_evsel *evsel_match(struct perf_evsel *evsel, |
371 | struct perf_evlist *evlist) | 338 | struct perf_evlist *evlist) |
372 | { | 339 | { |
@@ -520,7 +487,7 @@ static void hists__compute_resort(struct hists *hists) | |||
520 | 487 | ||
521 | static void hists__process(struct hists *old, struct hists *new) | 488 | static void hists__process(struct hists *old, struct hists *new) |
522 | { | 489 | { |
523 | hists__match(old, new); | 490 | hists__match(new, old); |
524 | 491 | ||
525 | if (show_baseline_only) | 492 | if (show_baseline_only) |
526 | hists__baseline_only(new); | 493 | hists__baseline_only(new); |