All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Stephane Eranian <eranian@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>
Subject: [PATCH 5/7] perf diff: Get rid of hists__compute_resort()
Date: Mon, 22 Dec 2014 13:44:13 +0900	[thread overview]
Message-ID: <1419223455-4362-6-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1419223455-4362-1-git-send-email-namhyung@kernel.org>

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>
---
 tools/perf/builtin-diff.c | 59 +++--------------------------------------------
 1 file 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)
 	return hist_entry__cmp_compute(right, left, COMPUTE_WEIGHTED_DIFF);
 }
 
-static void insert_hist_entry_by_compute(struct rb_root *root,
-					 struct hist_entry *he,
-					 int c)
-{
-	struct rb_node **p = &root->rb_node;
-	struct rb_node *parent = NULL;
-	struct hist_entry *iter;
-
-	while (*p != NULL) {
-		parent = *p;
-		iter = rb_entry(parent, struct hist_entry, rb_node);
-		if (hist_entry__cmp_compute(he, iter, c) < 0)
-			p = &(*p)->rb_left;
-		else
-			p = &(*p)->rb_right;
-	}
-
-	rb_link_node(&he->rb_node, parent, p);
-	rb_insert_color(&he->rb_node, root);
-}
-
-static void hists__compute_resort(struct hists *hists)
-{
-	struct rb_root *root;
-	struct rb_node *next;
-
-	if (sort__need_collapse)
-		root = &hists->entries_collapsed;
-	else
-		root = hists->entries_in;
-
-	hists->entries = RB_ROOT;
-	next = rb_first(root);
-
-	hists__reset_stats(hists);
-	hists__reset_col_len(hists);
-
-	while (next != NULL) {
-		struct hist_entry *he;
-
-		he = rb_entry(next, struct hist_entry, rb_node_in);
-		next = rb_next(&he->rb_node_in);
-
-		insert_hist_entry_by_compute(&hists->entries, he, compute);
-		hists__inc_stats(hists, he);
-
-		if (!he->filtered)
-			hists__calc_col_len(hists, he);
-	}
-}
-
 static void hists__process(struct hists *hists)
 {
 	if (show_baseline_only)
 		hists__baseline_only(hists);
 
-	if (sort_compute) {
+	if (sort_compute)
 		hists__precompute(hists);
-		hists__compute_resort(hists);
-	} else {
-		hists__output_resort(hists, NULL);
-	}
+
+	hists__output_resort(hists, NULL);
 
 	hists__fprintf(hists, true, 0, 0, 0, stdout);
 }
-- 
2.1.3


  parent reply	other threads:[~2014-12-22  4:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-22  4:44 [PATCHSET 0/7] perf tools: A small random cleanup and fixups Namhyung Kim
2014-12-22  4:44 ` [PATCH 1/7] perf report: Get rid of report__inc_stat() Namhyung Kim
2015-01-28 15:04   ` [tip:perf/core] " tip-bot for Namhyung Kim
2014-12-22  4:44 ` [PATCH 2/7] perf report: Show progress bar for output resorting Namhyung Kim
2015-01-01 21:28   ` [tip:perf/urgent] " tip-bot for Namhyung Kim
2014-12-22  4:44 ` [PATCH 3/7] perf ui/tui: Print backtrace symbols when segfault occurred Namhyung Kim
2015-01-01 21:28   ` [tip:perf/urgent] perf ui/tui: Print backtrace symbols when segfault occurs tip-bot for Namhyung Kim
2014-12-22  4:44 ` [PATCH 4/7] perf diff: Fix to sort by baseline field by default Namhyung Kim
2014-12-22 14:45   ` Arnaldo Carvalho de Melo
2014-12-23  4:12     ` Namhyung Kim
2014-12-23 13:30       ` Arnaldo Carvalho de Melo
2014-12-22  4:44 ` Namhyung Kim [this message]
2014-12-22  4:44 ` [PATCH 6/7] perf tools: Append callchains only when requested Namhyung Kim
2015-01-01 21:29   ` [tip:perf/urgent] perf callchain: " tip-bot for Namhyung Kim
2015-01-03  2:25   ` [PATCH 6/7] perf tools: " Arnaldo Carvalho de Melo
2015-01-03 15:01     ` Namhyung Kim
2015-01-05 12:49       ` Arnaldo Carvalho de Melo
2015-01-07  7:28         ` Namhyung Kim
2014-12-22  4:44 ` [PATCH 7/7] perf tools: Set attr.task bit for a tracking event Namhyung Kim
2014-12-22 14:49   ` Arnaldo Carvalho de Melo
2014-12-23  4:06     ` Namhyung Kim
2014-12-23 13:28       ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1419223455-4362-6-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.