aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2012-12-10 03:29:56 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-01-24 14:40:06 -0500
commit66f97ed3ac44c24958171bbc5cc04896147752b7 (patch)
tree6cd4c54d00a40853c5108367315b0aa90f2fc7d4
parentce74f60eab3cc8b7a3b0cb9c29ec9b1e1abac7d2 (diff)
perf diff: Use internal rb tree for compute resort
There's no reason to run hists_compute_resort() using output tree. Convert it to use internal tree so that it can remove unnecessary _output_resort. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1355128197-18193-4-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-diff.c31
-rw-r--r--tools/perf/util/hist.c2
-rw-r--r--tools/perf/util/hist.h1
3 files changed, 23 insertions, 11 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 8b896f5eded0..4af0b580b046 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -414,19 +414,30 @@ static void insert_hist_entry_by_compute(struct rb_root *root,
414 414
415static void hists__compute_resort(struct hists *hists) 415static void hists__compute_resort(struct hists *hists)
416{ 416{
417 struct rb_root tmp = RB_ROOT; 417 struct rb_root *root;
418 struct rb_node *next = rb_first(&hists->entries); 418 struct rb_node *next;
419
420 if (sort__need_collapse)
421 root = &hists->entries_collapsed;
422 else
423 root = hists->entries_in;
424
425 hists->entries = RB_ROOT;
426 next = rb_first(root);
427
428 hists->nr_entries = 0;
429 hists->stats.total_period = 0;
430 hists__reset_col_len(hists);
419 431
420 while (next != NULL) { 432 while (next != NULL) {
421 struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node); 433 struct hist_entry *he;
422 434
423 next = rb_next(&he->rb_node); 435 he = rb_entry(next, struct hist_entry, rb_node_in);
436 next = rb_next(&he->rb_node_in);
424 437
425 rb_erase(&he->rb_node, &hists->entries); 438 insert_hist_entry_by_compute(&hists->entries, he, compute);
426 insert_hist_entry_by_compute(&tmp, he, compute); 439 hists__inc_nr_entries(hists, he);
427 } 440 }
428
429 hists->entries = tmp;
430} 441}
431 442
432static void hists__process(struct hists *old, struct hists *new) 443static void hists__process(struct hists *old, struct hists *new)
@@ -438,11 +449,11 @@ static void hists__process(struct hists *old, struct hists *new)
438 else 449 else
439 hists__link(new, old); 450 hists__link(new, old);
440 451
441 hists__output_resort(new);
442
443 if (sort_compute) { 452 if (sort_compute) {
444 hists__precompute(new); 453 hists__precompute(new);
445 hists__compute_resort(new); 454 hists__compute_resort(new);
455 } else {
456 hists__output_resort(new);
446 } 457 }
447 458
448 hists__fprintf(new, true, 0, 0, stdout); 459 hists__fprintf(new, true, 0, 0, stdout);
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 8ff3c2f8a5dd..37179af74409 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -251,7 +251,7 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template)
251 return he; 251 return he;
252} 252}
253 253
254static void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h) 254void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h)
255{ 255{
256 if (!h->filtered) { 256 if (!h->filtered) {
257 hists__calc_col_len(hists, h); 257 hists__calc_col_len(hists, h);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 5b3b0075be64..d3664abea6d6 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -96,6 +96,7 @@ void hists__decay_entries_threaded(struct hists *hists, bool zap_user,
96 bool zap_kernel); 96 bool zap_kernel);
97void hists__output_recalc_col_len(struct hists *hists, int max_rows); 97void hists__output_recalc_col_len(struct hists *hists, int max_rows);
98 98
99void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h);
99void hists__inc_nr_events(struct hists *self, u32 type); 100void hists__inc_nr_events(struct hists *self, u32 type);
100size_t hists__fprintf_nr_events(struct hists *self, FILE *fp); 101size_t hists__fprintf_nr_events(struct hists *self, FILE *fp);
101 102