perf diff: Move hists__match to the hists lib
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 8 Nov 2012 20:54:33 +0000 (17:54 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 8 Nov 2012 20:57:37 +0000 (17:57 -0300)
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>
tools/perf/builtin-diff.c
tools/perf/util/hist.c
tools/perf/util/hist.h

index 8a9db38e562f8a0769a3ca7d029b8261fbb7e7b4..e99fb3bc1c2dc61ab6c69c35c50bc06680532fd3 100644 (file)
@@ -334,39 +334,6 @@ static void hists__name_resort(struct hists *self, bool sort)
                self->entries = tmp;
 }
 
-static struct hist_entry *hists__find_entry(struct hists *self,
-                                           struct hist_entry *he)
-{
-       struct rb_node *n = self->entries.rb_node;
-
-       while (n) {
-               struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node);
-               int64_t cmp = hist_entry__cmp(he, iter);
-
-               if (cmp < 0)
-                       n = n->rb_left;
-               else if (cmp > 0)
-                       n = n->rb_right;
-               else
-                       return iter;
-       }
-
-       return NULL;
-}
-
-static void hists__match(struct hists *older, struct hists *newer)
-{
-       struct rb_node *nd;
-
-       for (nd = rb_first(&newer->entries); nd; nd = rb_next(nd)) {
-               struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node),
-                                 *pair = hists__find_entry(older, pos);
-
-               if (pair)
-                       hist__entry_add_pair(pos, pair);
-       }
-}
-
 static struct perf_evsel *evsel_match(struct perf_evsel *evsel,
                                      struct perf_evlist *evlist)
 {
@@ -520,7 +487,7 @@ static void hists__compute_resort(struct hists *hists)
 
 static void hists__process(struct hists *old, struct hists *new)
 {
-       hists__match(old, new);
+       hists__match(new, old);
 
        if (show_baseline_only)
                hists__baseline_only(new);
index f42de79d2e6b508035798eb3eadeb4f23cdfa106..c1de3b05fe09b5dcfa97493c39dd5d77e4b30648 100644 (file)
@@ -716,3 +716,40 @@ void hists__inc_nr_events(struct hists *hists, u32 type)
        ++hists->stats.nr_events[0];
        ++hists->stats.nr_events[type];
 }
+
+static struct hist_entry *hists__find_entry(struct hists *hists,
+                                           struct hist_entry *he)
+{
+       struct rb_node *n = hists->entries.rb_node;
+
+       while (n) {
+               struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node);
+               int64_t cmp = hist_entry__cmp(he, iter);
+
+               if (cmp < 0)
+                       n = n->rb_left;
+               else if (cmp > 0)
+                       n = n->rb_right;
+               else
+                       return iter;
+       }
+
+       return NULL;
+}
+
+/*
+ * Look for pairs to link to the leader buckets (hist_entries):
+ */
+void hists__match(struct hists *leader, struct hists *other)
+{
+       struct rb_node *nd;
+       struct hist_entry *pos, *pair;
+
+       for (nd = rb_first(&leader->entries); nd; nd = rb_next(nd)) {
+               pos  = rb_entry(nd, struct hist_entry, rb_node);
+               pair = hists__find_entry(other, pos);
+
+               if (pair)
+                       hist__entry_add_pair(pos, pair);
+       }
+}
index a4f45dd046971e5836f9f2215713bdf6b9f375a8..ff1c3963e04f110618e922cb18ccbf180a563a1c 100644 (file)
@@ -115,6 +115,8 @@ bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len);
 void hists__reset_col_len(struct hists *hists);
 void hists__calc_col_len(struct hists *hists, struct hist_entry *he);
 
+void hists__match(struct hists *leader, struct hists *other);
+
 struct perf_hpp {
        char *buf;
        size_t size;
This page took 0.028872 seconds and 5 git commands to generate.