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/util/hist.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/util/hist.c')
-rw-r--r-- | tools/perf/util/hist.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index f42de79d2e6b..c1de3b05fe09 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -716,3 +716,40 @@ void hists__inc_nr_events(struct hists *hists, u32 type) | |||
716 | ++hists->stats.nr_events[0]; | 716 | ++hists->stats.nr_events[0]; |
717 | ++hists->stats.nr_events[type]; | 717 | ++hists->stats.nr_events[type]; |
718 | } | 718 | } |
719 | |||
720 | static struct hist_entry *hists__find_entry(struct hists *hists, | ||
721 | struct hist_entry *he) | ||
722 | { | ||
723 | struct rb_node *n = hists->entries.rb_node; | ||
724 | |||
725 | while (n) { | ||
726 | struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node); | ||
727 | int64_t cmp = hist_entry__cmp(he, iter); | ||
728 | |||
729 | if (cmp < 0) | ||
730 | n = n->rb_left; | ||
731 | else if (cmp > 0) | ||
732 | n = n->rb_right; | ||
733 | else | ||
734 | return iter; | ||
735 | } | ||
736 | |||
737 | return NULL; | ||
738 | } | ||
739 | |||
740 | /* | ||
741 | * Look for pairs to link to the leader buckets (hist_entries): | ||
742 | */ | ||
743 | void hists__match(struct hists *leader, struct hists *other) | ||
744 | { | ||
745 | struct rb_node *nd; | ||
746 | struct hist_entry *pos, *pair; | ||
747 | |||
748 | for (nd = rb_first(&leader->entries); nd; nd = rb_next(nd)) { | ||
749 | pos = rb_entry(nd, struct hist_entry, rb_node); | ||
750 | pair = hists__find_entry(other, pos); | ||
751 | |||
752 | if (pair) | ||
753 | hist__entry_add_pair(pos, pair); | ||
754 | } | ||
755 | } | ||