aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2015-01-07 19:45:47 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-01-21 11:24:34 -0500
commit56495a8affabe35aa0d94aae050d3e0e60d0455f (patch)
tree4fb374ac1b37cb90632e5feeabd8c7c5db2fd352 /tools/perf
parent87bbdf768ff962f1c04d3b8f6db1e179279132d1 (diff)
perf diff: Fix output ordering to honor next column
When perf diff prints output, it sorts the entries using baseline field by default, but entries which don't have baseline are not sorted properly. This patch makes it sorted by values of next column. Before: # Baseline/0 Delta/1 Delta/2 Shared Object Symbol # .......... ....... ....... ................. .......................................... # 32.75% +0.28% -0.83% libc-2.20.so [.] malloc 31.50% -0.74% -0.23% libc-2.20.so [.] _int_free 22.98% +0.51% +0.52% libc-2.20.so [.] _int_malloc 5.70% +0.28% +0.30% libc-2.20.so [.] free 4.38% -0.21% +0.25% a.out [.] main 1.32% -0.15% +0.05% a.out [.] free@plt 1.31% +0.03% -0.06% a.out [.] malloc@plt 0.01% -0.01% -0.01% [kernel.kallsyms] [k] native_write_msr_safe 0.01% [kernel.kallsyms] [k] scheduler_tick 0.01% -0.00% [kernel.kallsyms] [k] native_read_msr_safe +0.01% [kernel.kallsyms] [k] _raw_spin_lock_irqsave +0.01% +0.01% [kernel.kallsyms] [k] apic_timer_interrupt +0.01% [kernel.kallsyms] [k] intel_pstate_timer_func +0.01% [kernel.kallsyms] [k] perf_adjust_freq_unthr_context.part.82 +0.01% [kernel.kallsyms] [k] read_tsc +0.01% [kernel.kallsyms] [k] timekeeping_update.constprop.8 After: # Baseline/0 Delta/1 Delta/2 Shared Object Symbol # .......... ....... ....... ................. .......................................... # 32.75% +0.28% -0.83% libc-2.20.so [.] malloc 31.50% -0.74% -0.23% libc-2.20.so [.] _int_free 22.98% +0.51% +0.52% libc-2.20.so [.] _int_malloc 5.70% +0.28% +0.30% libc-2.20.so [.] free 4.38% -0.21% +0.25% a.out [.] main 1.32% -0.15% +0.05% a.out [.] free@plt 1.31% +0.03% -0.06% a.out [.] malloc@plt 0.01% -0.01% -0.01% [kernel.kallsyms] [k] native_write_msr_safe 0.01% [kernel.kallsyms] [k] scheduler_tick 0.01% -0.00% [kernel.kallsyms] [k] native_read_msr_safe +0.01% +0.01% [kernel.kallsyms] [k] apic_timer_interrupt +0.01% [kernel.kallsyms] [k] read_tsc +0.01% [kernel.kallsyms] [k] perf_adjust_freq_unthr_context.part.82 +0.01% [kernel.kallsyms] [k] intel_pstate_timer_func +0.01% [kernel.kallsyms] [k] _raw_spin_lock_irqsave +0.01% [kernel.kallsyms] [k] timekeeping_update.constprop.8 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: Kan Liang <kan.liang@intel.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1420677949-6719-7-git-send-email-namhyung@kernel.org [ Fixed up hist_entry__cmp_ method signatures, fallout from making previous cset buildable ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-diff.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 4816989a84b0..98444561d9b4 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -456,26 +456,30 @@ static void hists__precompute(struct hists *hists)
456 next = rb_first(root); 456 next = rb_first(root);
457 while (next != NULL) { 457 while (next != NULL) {
458 struct hist_entry *he, *pair; 458 struct hist_entry *he, *pair;
459 struct data__file *d;
460 int i;
459 461
460 he = rb_entry(next, struct hist_entry, rb_node_in); 462 he = rb_entry(next, struct hist_entry, rb_node_in);
461 next = rb_next(&he->rb_node_in); 463 next = rb_next(&he->rb_node_in);
462 464
463 pair = get_pair_data(he, &data__files[sort_compute]); 465 data__for_each_file_new(i, d) {
464 if (!pair) 466 pair = get_pair_data(he, d);
465 continue; 467 if (!pair)
468 continue;
466 469
467 switch (compute) { 470 switch (compute) {
468 case COMPUTE_DELTA: 471 case COMPUTE_DELTA:
469 compute_delta(he, pair); 472 compute_delta(he, pair);
470 break; 473 break;
471 case COMPUTE_RATIO: 474 case COMPUTE_RATIO:
472 compute_ratio(he, pair); 475 compute_ratio(he, pair);
473 break; 476 break;
474 case COMPUTE_WEIGHTED_DIFF: 477 case COMPUTE_WEIGHTED_DIFF:
475 compute_wdiff(he, pair); 478 compute_wdiff(he, pair);
476 break; 479 break;
477 default: 480 default:
478 BUG_ON(1); 481 BUG_ON(1);
482 }
479 } 483 }
480 } 484 }
481} 485}
@@ -525,7 +529,7 @@ __hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right,
525 529
526static int64_t 530static int64_t
527hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right, 531hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right,
528 int c) 532 int c, int sort_idx)
529{ 533{
530 bool pairs_left = hist_entry__has_pairs(left); 534 bool pairs_left = hist_entry__has_pairs(left);
531 bool pairs_right = hist_entry__has_pairs(right); 535 bool pairs_right = hist_entry__has_pairs(right);
@@ -537,8 +541,8 @@ hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right,
537 if (!pairs_left || !pairs_right) 541 if (!pairs_left || !pairs_right)
538 return pairs_left ? -1 : 1; 542 return pairs_left ? -1 : 1;
539 543
540 p_left = get_pair_data(left, &data__files[sort_compute]); 544 p_left = get_pair_data(left, &data__files[sort_idx]);
541 p_right = get_pair_data(right, &data__files[sort_compute]); 545 p_right = get_pair_data(right, &data__files[sort_idx]);
542 546
543 if (!p_left && !p_right) 547 if (!p_left && !p_right)
544 return 0; 548 return 0;
@@ -565,33 +569,36 @@ static int64_t
565hist_entry__cmp_baseline(struct perf_hpp_fmt *fmt __maybe_unused, 569hist_entry__cmp_baseline(struct perf_hpp_fmt *fmt __maybe_unused,
566 struct hist_entry *left, struct hist_entry *right) 570 struct hist_entry *left, struct hist_entry *right)
567{ 571{
568 if (sort_compute)
569 return 0;
570
571 if (left->stat.period == right->stat.period) 572 if (left->stat.period == right->stat.period)
572 return 0; 573 return 0;
573 return left->stat.period > right->stat.period ? 1 : -1; 574 return left->stat.period > right->stat.period ? 1 : -1;
574} 575}
575 576
576static int64_t 577static int64_t
577hist_entry__cmp_delta(struct perf_hpp_fmt *fmt __maybe_unused, 578hist_entry__cmp_delta(struct perf_hpp_fmt *fmt,
578 struct hist_entry *left, struct hist_entry *right) 579 struct hist_entry *left, struct hist_entry *right)
579{ 580{
580 return hist_entry__cmp_compute(right, left, COMPUTE_DELTA); 581 struct data__file *d = fmt_to_data_file(fmt);
582
583 return hist_entry__cmp_compute(right, left, COMPUTE_DELTA, d->idx);
581} 584}
582 585
583static int64_t 586static int64_t
584hist_entry__cmp_ratio(struct perf_hpp_fmt *fmt __maybe_unused, 587hist_entry__cmp_ratio(struct perf_hpp_fmt *fmt,
585 struct hist_entry *left, struct hist_entry *right) 588 struct hist_entry *left, struct hist_entry *right)
586{ 589{
587 return hist_entry__cmp_compute(right, left, COMPUTE_RATIO); 590 struct data__file *d = fmt_to_data_file(fmt);
591
592 return hist_entry__cmp_compute(right, left, COMPUTE_RATIO, d->idx);
588} 593}
589 594
590static int64_t 595static int64_t
591hist_entry__cmp_wdiff(struct perf_hpp_fmt *fmt __maybe_unused, 596hist_entry__cmp_wdiff(struct perf_hpp_fmt *fmt,
592 struct hist_entry *left, struct hist_entry *right) 597 struct hist_entry *left, struct hist_entry *right)
593{ 598{
594 return hist_entry__cmp_compute(right, left, COMPUTE_WEIGHTED_DIFF); 599 struct data__file *d = fmt_to_data_file(fmt);
600
601 return hist_entry__cmp_compute(right, left, COMPUTE_WEIGHTED_DIFF, d->idx);
595} 602}
596 603
597static void hists__process(struct hists *hists) 604static void hists__process(struct hists *hists)
@@ -599,9 +606,7 @@ static void hists__process(struct hists *hists)
599 if (show_baseline_only) 606 if (show_baseline_only)
600 hists__baseline_only(hists); 607 hists__baseline_only(hists);
601 608
602 if (sort_compute) 609 hists__precompute(hists);
603 hists__precompute(hists);
604
605 hists__output_resort(hists, NULL); 610 hists__output_resort(hists, NULL);
606 611
607 hists__fprintf(hists, true, 0, 0, 0, stdout); 612 hists__fprintf(hists, true, 0, 0, 0, stdout);