aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2014-12-27 00:06:30 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-01-21 11:24:33 -0500
commit38259a170dfab4865968b592ae90b373e9f7d5b5 (patch)
treeaa97f15d0ff1628a1055ef8800ebf51893964f02 /tools/perf
parent5594b557aacaafbba7ad8e5ed29005df883bfe3a (diff)
perf diff: Get rid of hists__compute_resort()
The hists__compute_resort() is to sort output fields based on the given field/criteria. This was done without the sort list but as we added the field to the sort list, we can do it with normal hists__output_resort() using the ->sort callback. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1419656793-32756-2-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-diff.c59
1 files changed, 3 insertions, 56 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 318ab9c3f0ba..72c718e6549c 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -581,68 +581,15 @@ hist_entry__cmp_wdiff(struct hist_entry *left, struct hist_entry *right)
581 return hist_entry__cmp_compute(right, left, COMPUTE_WEIGHTED_DIFF); 581 return hist_entry__cmp_compute(right, left, COMPUTE_WEIGHTED_DIFF);
582} 582}
583 583
584static void insert_hist_entry_by_compute(struct rb_root *root,
585 struct hist_entry *he,
586 int c)
587{
588 struct rb_node **p = &root->rb_node;
589 struct rb_node *parent = NULL;
590 struct hist_entry *iter;
591
592 while (*p != NULL) {
593 parent = *p;
594 iter = rb_entry(parent, struct hist_entry, rb_node);
595 if (hist_entry__cmp_compute(he, iter, c) < 0)
596 p = &(*p)->rb_left;
597 else
598 p = &(*p)->rb_right;
599 }
600
601 rb_link_node(&he->rb_node, parent, p);
602 rb_insert_color(&he->rb_node, root);
603}
604
605static void hists__compute_resort(struct hists *hists)
606{
607 struct rb_root *root;
608 struct rb_node *next;
609
610 if (sort__need_collapse)
611 root = &hists->entries_collapsed;
612 else
613 root = hists->entries_in;
614
615 hists->entries = RB_ROOT;
616 next = rb_first(root);
617
618 hists__reset_stats(hists);
619 hists__reset_col_len(hists);
620
621 while (next != NULL) {
622 struct hist_entry *he;
623
624 he = rb_entry(next, struct hist_entry, rb_node_in);
625 next = rb_next(&he->rb_node_in);
626
627 insert_hist_entry_by_compute(&hists->entries, he, compute);
628 hists__inc_stats(hists, he);
629
630 if (!he->filtered)
631 hists__calc_col_len(hists, he);
632 }
633}
634
635static void hists__process(struct hists *hists) 584static void hists__process(struct hists *hists)
636{ 585{
637 if (show_baseline_only) 586 if (show_baseline_only)
638 hists__baseline_only(hists); 587 hists__baseline_only(hists);
639 588
640 if (sort_compute) { 589 if (sort_compute)
641 hists__precompute(hists); 590 hists__precompute(hists);
642 hists__compute_resort(hists); 591
643 } else { 592 hists__output_resort(hists, NULL);
644 hists__output_resort(hists, NULL);
645 }
646 593
647 hists__fprintf(hists, true, 0, 0, 0, stdout); 594 hists__fprintf(hists, true, 0, 0, 0, stdout);
648} 595}