diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/hist.c | 62 |
1 files changed, 8 insertions, 54 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 38373c986e97..c99ae4dd973e 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -564,64 +564,18 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog) | |||
564 | } | 564 | } |
565 | } | 565 | } |
566 | 566 | ||
567 | /* | 567 | static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b) |
568 | * reverse the map, sort on period. | ||
569 | */ | ||
570 | |||
571 | static int period_cmp(u64 period_a, u64 period_b) | ||
572 | { | 568 | { |
573 | if (period_a > period_b) | 569 | struct perf_hpp_fmt *fmt; |
574 | return 1; | 570 | int64_t cmp = 0; |
575 | if (period_a < period_b) | ||
576 | return -1; | ||
577 | return 0; | ||
578 | } | ||
579 | |||
580 | static int hist_entry__sort_on_period(struct hist_entry *a, | ||
581 | struct hist_entry *b) | ||
582 | { | ||
583 | int ret; | ||
584 | int i, nr_members; | ||
585 | struct perf_evsel *evsel; | ||
586 | struct hist_entry *pair; | ||
587 | u64 *periods_a, *periods_b; | ||
588 | |||
589 | ret = period_cmp(a->stat.period, b->stat.period); | ||
590 | if (ret || !symbol_conf.event_group) | ||
591 | return ret; | ||
592 | |||
593 | evsel = hists_to_evsel(a->hists); | ||
594 | nr_members = evsel->nr_members; | ||
595 | if (nr_members <= 1) | ||
596 | return ret; | ||
597 | |||
598 | periods_a = zalloc(sizeof(periods_a) * nr_members); | ||
599 | periods_b = zalloc(sizeof(periods_b) * nr_members); | ||
600 | |||
601 | if (!periods_a || !periods_b) | ||
602 | goto out; | ||
603 | |||
604 | list_for_each_entry(pair, &a->pairs.head, pairs.node) { | ||
605 | evsel = hists_to_evsel(pair->hists); | ||
606 | periods_a[perf_evsel__group_idx(evsel)] = pair->stat.period; | ||
607 | } | ||
608 | |||
609 | list_for_each_entry(pair, &b->pairs.head, pairs.node) { | ||
610 | evsel = hists_to_evsel(pair->hists); | ||
611 | periods_b[perf_evsel__group_idx(evsel)] = pair->stat.period; | ||
612 | } | ||
613 | 571 | ||
614 | for (i = 1; i < nr_members; i++) { | 572 | perf_hpp__for_each_format(fmt) { |
615 | ret = period_cmp(periods_a[i], periods_b[i]); | 573 | cmp = fmt->sort(a, b); |
616 | if (ret) | 574 | if (cmp) |
617 | break; | 575 | break; |
618 | } | 576 | } |
619 | 577 | ||
620 | out: | 578 | return cmp; |
621 | free(periods_a); | ||
622 | free(periods_b); | ||
623 | |||
624 | return ret; | ||
625 | } | 579 | } |
626 | 580 | ||
627 | static void hists__reset_filter_stats(struct hists *hists) | 581 | static void hists__reset_filter_stats(struct hists *hists) |
@@ -669,7 +623,7 @@ static void __hists__insert_output_entry(struct rb_root *entries, | |||
669 | parent = *p; | 623 | parent = *p; |
670 | iter = rb_entry(parent, struct hist_entry, rb_node); | 624 | iter = rb_entry(parent, struct hist_entry, rb_node); |
671 | 625 | ||
672 | if (hist_entry__sort_on_period(he, iter) > 0) | 626 | if (hist_entry__sort(he, iter) > 0) |
673 | p = &(*p)->rb_left; | 627 | p = &(*p)->rb_left; |
674 | else | 628 | else |
675 | p = &(*p)->rb_right; | 629 | p = &(*p)->rb_right; |