diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-01-13 21:52:48 -0500 |
---|---|---|
committer | Jiri Olsa <jolsa@redhat.com> | 2014-04-16 11:16:03 -0400 |
commit | f2148330544a697481219b5bc34261f6dd049bfb (patch) | |
tree | b08733dad6f875401f8751e7f7402443372d28eb /tools/perf/util/hist.c | |
parent | 1ab1fa5dfb429c533fbc791e524788cf0cc43775 (diff) |
perf report: Add --percentage option
The --percentage option is for controlling overhead percentage
displayed. It can only receive either of "relative" or "absolute".
"relative" means it's relative to filtered entries only so that the
sum of shown entries will be always 100%. "absolute" means it retains
the original value before and after the filter is applied.
$ perf report -s comm
# Overhead Command
# ........ ............
#
74.19% cc1
7.61% gcc
6.11% as
4.35% sh
4.14% make
1.13% fixdep
...
$ perf report -s comm -c cc1,gcc --percentage absolute
# Overhead Command
# ........ ............
#
74.19% cc1
7.61% gcc
$ perf report -s comm -c cc1,gcc --percentage relative
# Overhead Command
# ........ ............
#
90.69% cc1
9.31% gcc
Note that it has zero effect if no filter was applied.
Suggested-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1397145720-8063-3-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Diffstat (limited to 'tools/perf/util/hist.c')
-rw-r--r-- | tools/perf/util/hist.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 1ed3e2b86f0b..3ebd89a28257 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -321,9 +321,11 @@ void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h) | |||
321 | { | 321 | { |
322 | if (!h->filtered) { | 322 | if (!h->filtered) { |
323 | hists__calc_col_len(hists, h); | 323 | hists__calc_col_len(hists, h); |
324 | ++hists->nr_entries; | 324 | hists->nr_non_filtered_entries++; |
325 | hists->stats.total_period += h->stat.period; | 325 | hists->stats.total_non_filtered_period += h->stat.period; |
326 | } | 326 | } |
327 | hists->nr_entries++; | ||
328 | hists->stats.total_period += h->stat.period; | ||
327 | } | 329 | } |
328 | 330 | ||
329 | static u8 symbol__parent_filter(const struct symbol *parent) | 331 | static u8 symbol__parent_filter(const struct symbol *parent) |
@@ -674,8 +676,9 @@ void hists__output_resort(struct hists *hists) | |||
674 | next = rb_first(root); | 676 | next = rb_first(root); |
675 | hists->entries = RB_ROOT; | 677 | hists->entries = RB_ROOT; |
676 | 678 | ||
677 | hists->nr_entries = hists->nr_non_filtered_entries = 0; | 679 | hists->nr_non_filtered_entries = 0; |
678 | hists->stats.total_period = hists->stats.total_non_filtered_period = 0; | 680 | hists->stats.total_period = 0; |
681 | hists->stats.total_non_filtered_period = 0; | ||
679 | hists__reset_col_len(hists); | 682 | hists__reset_col_len(hists); |
680 | 683 | ||
681 | while (next) { | 684 | while (next) { |
@@ -694,16 +697,11 @@ static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h | |||
694 | if (h->filtered) | 697 | if (h->filtered) |
695 | return; | 698 | return; |
696 | 699 | ||
697 | ++hists->nr_entries; | ||
698 | ++hists->nr_non_filtered_entries; | 700 | ++hists->nr_non_filtered_entries; |
699 | if (h->ms.unfolded) { | 701 | if (h->ms.unfolded) |
700 | hists->nr_entries += h->nr_rows; | ||
701 | hists->nr_non_filtered_entries += h->nr_rows; | 702 | hists->nr_non_filtered_entries += h->nr_rows; |
702 | } | ||
703 | h->row_offset = 0; | 703 | h->row_offset = 0; |
704 | hists->stats.total_period += h->stat.period; | ||
705 | hists->stats.total_non_filtered_period += h->stat.period; | 704 | hists->stats.total_non_filtered_period += h->stat.period; |
706 | hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->stat.nr_events; | ||
707 | hists->stats.nr_non_filtered_samples += h->stat.nr_events; | 705 | hists->stats.nr_non_filtered_samples += h->stat.nr_events; |
708 | 706 | ||
709 | hists__calc_col_len(hists, h); | 707 | hists__calc_col_len(hists, h); |
@@ -726,9 +724,8 @@ void hists__filter_by_dso(struct hists *hists) | |||
726 | { | 724 | { |
727 | struct rb_node *nd; | 725 | struct rb_node *nd; |
728 | 726 | ||
729 | hists->nr_entries = hists->stats.total_period = 0; | 727 | hists->nr_non_filtered_entries = 0; |
730 | hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; | 728 | hists->stats.total_non_filtered_period = 0; |
731 | hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; | ||
732 | hists->stats.nr_non_filtered_samples = 0; | 729 | hists->stats.nr_non_filtered_samples = 0; |
733 | hists__reset_col_len(hists); | 730 | hists__reset_col_len(hists); |
734 | 731 | ||
@@ -761,9 +758,8 @@ void hists__filter_by_thread(struct hists *hists) | |||
761 | { | 758 | { |
762 | struct rb_node *nd; | 759 | struct rb_node *nd; |
763 | 760 | ||
764 | hists->nr_entries = hists->stats.total_period = 0; | 761 | hists->nr_non_filtered_entries = 0; |
765 | hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; | 762 | hists->stats.total_non_filtered_period = 0; |
766 | hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; | ||
767 | hists->stats.nr_non_filtered_samples = 0; | 763 | hists->stats.nr_non_filtered_samples = 0; |
768 | hists__reset_col_len(hists); | 764 | hists__reset_col_len(hists); |
769 | 765 | ||
@@ -794,9 +790,8 @@ void hists__filter_by_symbol(struct hists *hists) | |||
794 | { | 790 | { |
795 | struct rb_node *nd; | 791 | struct rb_node *nd; |
796 | 792 | ||
797 | hists->nr_entries = hists->stats.total_period = 0; | 793 | hists->nr_non_filtered_entries = 0; |
798 | hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; | 794 | hists->stats.total_non_filtered_period = 0; |
799 | hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; | ||
800 | hists->stats.nr_non_filtered_samples = 0; | 795 | hists->stats.nr_non_filtered_samples = 0; |
801 | hists__reset_col_len(hists); | 796 | hists__reset_col_len(hists); |
802 | 797 | ||
@@ -942,3 +937,9 @@ int hists__link(struct hists *leader, struct hists *other) | |||
942 | 937 | ||
943 | return 0; | 938 | return 0; |
944 | } | 939 | } |
940 | |||
941 | u64 hists__total_period(struct hists *hists) | ||
942 | { | ||
943 | return symbol_conf.filter_relative ? hists->stats.total_non_filtered_period : | ||
944 | hists->stats.total_period; | ||
945 | } | ||