diff options
| -rw-r--r-- | tools/perf/builtin-diff.c | 35 | ||||
| -rw-r--r-- | tools/perf/util/hist.c | 37 | ||||
| -rw-r--r-- | tools/perf/util/hist.h | 2 |
3 files changed, 40 insertions, 34 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 8a9db38e562..e99fb3bc1c2 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); |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index f42de79d2e6..c1de3b05fe0 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 | } | ||
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index a4f45dd0469..ff1c3963e04 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
| @@ -115,6 +115,8 @@ bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len); | |||
| 115 | void hists__reset_col_len(struct hists *hists); | 115 | void hists__reset_col_len(struct hists *hists); |
| 116 | void hists__calc_col_len(struct hists *hists, struct hist_entry *he); | 116 | void hists__calc_col_len(struct hists *hists, struct hist_entry *he); |
| 117 | 117 | ||
| 118 | void hists__match(struct hists *leader, struct hists *other); | ||
| 119 | |||
| 118 | struct perf_hpp { | 120 | struct perf_hpp { |
| 119 | char *buf; | 121 | char *buf; |
| 120 | size_t size; | 122 | size_t size; |
