diff options
author | Namhyung Kim <namhyung@kernel.org> | 2013-12-26 01:11:52 -0500 |
---|---|---|
committer | Jiri Olsa <jolsa@redhat.com> | 2014-04-16 11:16:03 -0400 |
commit | 1ab1fa5dfb429c533fbc791e524788cf0cc43775 (patch) | |
tree | 498386cc0e6342a7228e86f3a59da86179e62e5a /tools | |
parent | fbdd17ec5ce2e5e4027356fcfde769b88d15702f (diff) |
perf hists: Add support for showing relative percentage
When filtering by thread, dso or symbol on TUI it also update total
period so that the output shows different result than no filter - the
percentage changed to relative to filtered entries only. Sometimes
this is not desired since users might expect same results with filter.
So new filtered_* fields to hists->stats to count them separately.
They'll be controlled/used by user later.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1397145720-8063-2-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-report.c | 6 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 3 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 17 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 3 |
4 files changed, 26 insertions, 3 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c8f21137dfd8..2fca56c9d68a 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -123,6 +123,8 @@ static int report__add_mem_hist_entry(struct report *rep, struct addr_location * | |||
123 | 123 | ||
124 | evsel->hists.stats.total_period += cost; | 124 | evsel->hists.stats.total_period += cost; |
125 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); | 125 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); |
126 | if (!he->filtered) | ||
127 | evsel->hists.stats.nr_non_filtered_samples++; | ||
126 | err = hist_entry__append_callchain(he, sample); | 128 | err = hist_entry__append_callchain(he, sample); |
127 | out: | 129 | out: |
128 | return err; | 130 | return err; |
@@ -176,6 +178,8 @@ static int report__add_branch_hist_entry(struct report *rep, struct addr_locatio | |||
176 | 178 | ||
177 | evsel->hists.stats.total_period += 1; | 179 | evsel->hists.stats.total_period += 1; |
178 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); | 180 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); |
181 | if (!he->filtered) | ||
182 | evsel->hists.stats.nr_non_filtered_samples++; | ||
179 | } else | 183 | } else |
180 | goto out; | 184 | goto out; |
181 | } | 185 | } |
@@ -209,6 +213,8 @@ static int report__add_hist_entry(struct report *rep, struct perf_evsel *evsel, | |||
209 | err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); | 213 | err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); |
210 | 214 | ||
211 | evsel->hists.stats.total_period += sample->period; | 215 | evsel->hists.stats.total_period += sample->period; |
216 | if (!he->filtered) | ||
217 | evsel->hists.stats.nr_non_filtered_samples++; | ||
212 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); | 218 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); |
213 | out: | 219 | out: |
214 | return err; | 220 | return err; |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 65aaa5bbf7ec..25269014164a 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -253,6 +253,9 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel, | |||
253 | return NULL; | 253 | return NULL; |
254 | 254 | ||
255 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); | 255 | hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); |
256 | if (!he->filtered) | ||
257 | evsel->hists.stats.nr_non_filtered_samples++; | ||
258 | |||
256 | return he; | 259 | return he; |
257 | } | 260 | } |
258 | 261 | ||
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index f38590d7561b..1ed3e2b86f0b 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -674,8 +674,8 @@ void hists__output_resort(struct hists *hists) | |||
674 | next = rb_first(root); | 674 | next = rb_first(root); |
675 | hists->entries = RB_ROOT; | 675 | hists->entries = RB_ROOT; |
676 | 676 | ||
677 | hists->nr_entries = 0; | 677 | hists->nr_entries = hists->nr_non_filtered_entries = 0; |
678 | hists->stats.total_period = 0; | 678 | hists->stats.total_period = hists->stats.total_non_filtered_period = 0; |
679 | hists__reset_col_len(hists); | 679 | hists__reset_col_len(hists); |
680 | 680 | ||
681 | while (next) { | 681 | while (next) { |
@@ -695,11 +695,16 @@ static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h | |||
695 | return; | 695 | return; |
696 | 696 | ||
697 | ++hists->nr_entries; | 697 | ++hists->nr_entries; |
698 | if (h->ms.unfolded) | 698 | ++hists->nr_non_filtered_entries; |
699 | if (h->ms.unfolded) { | ||
699 | hists->nr_entries += h->nr_rows; | 700 | hists->nr_entries += h->nr_rows; |
701 | hists->nr_non_filtered_entries += h->nr_rows; | ||
702 | } | ||
700 | h->row_offset = 0; | 703 | h->row_offset = 0; |
701 | hists->stats.total_period += h->stat.period; | 704 | hists->stats.total_period += h->stat.period; |
705 | hists->stats.total_non_filtered_period += h->stat.period; | ||
702 | hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->stat.nr_events; | 706 | hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->stat.nr_events; |
707 | hists->stats.nr_non_filtered_samples += h->stat.nr_events; | ||
703 | 708 | ||
704 | hists__calc_col_len(hists, h); | 709 | hists__calc_col_len(hists, h); |
705 | } | 710 | } |
@@ -722,7 +727,9 @@ void hists__filter_by_dso(struct hists *hists) | |||
722 | struct rb_node *nd; | 727 | struct rb_node *nd; |
723 | 728 | ||
724 | hists->nr_entries = hists->stats.total_period = 0; | 729 | hists->nr_entries = hists->stats.total_period = 0; |
730 | hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; | ||
725 | hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; | 731 | hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; |
732 | hists->stats.nr_non_filtered_samples = 0; | ||
726 | hists__reset_col_len(hists); | 733 | hists__reset_col_len(hists); |
727 | 734 | ||
728 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { | 735 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
@@ -755,7 +762,9 @@ void hists__filter_by_thread(struct hists *hists) | |||
755 | struct rb_node *nd; | 762 | struct rb_node *nd; |
756 | 763 | ||
757 | hists->nr_entries = hists->stats.total_period = 0; | 764 | hists->nr_entries = hists->stats.total_period = 0; |
765 | hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; | ||
758 | hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; | 766 | hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; |
767 | hists->stats.nr_non_filtered_samples = 0; | ||
759 | hists__reset_col_len(hists); | 768 | hists__reset_col_len(hists); |
760 | 769 | ||
761 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { | 770 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
@@ -786,7 +795,9 @@ void hists__filter_by_symbol(struct hists *hists) | |||
786 | struct rb_node *nd; | 795 | struct rb_node *nd; |
787 | 796 | ||
788 | hists->nr_entries = hists->stats.total_period = 0; | 797 | hists->nr_entries = hists->stats.total_period = 0; |
798 | hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; | ||
789 | hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; | 799 | hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; |
800 | hists->stats.nr_non_filtered_samples = 0; | ||
790 | hists__reset_col_len(hists); | 801 | hists__reset_col_len(hists); |
791 | 802 | ||
792 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { | 803 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 1f1f513dfe7f..213551469f36 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -37,9 +37,11 @@ enum hist_filter { | |||
37 | */ | 37 | */ |
38 | struct events_stats { | 38 | struct events_stats { |
39 | u64 total_period; | 39 | u64 total_period; |
40 | u64 total_non_filtered_period; | ||
40 | u64 total_lost; | 41 | u64 total_lost; |
41 | u64 total_invalid_chains; | 42 | u64 total_invalid_chains; |
42 | u32 nr_events[PERF_RECORD_HEADER_MAX]; | 43 | u32 nr_events[PERF_RECORD_HEADER_MAX]; |
44 | u32 nr_non_filtered_samples; | ||
43 | u32 nr_lost_warned; | 45 | u32 nr_lost_warned; |
44 | u32 nr_unknown_events; | 46 | u32 nr_unknown_events; |
45 | u32 nr_invalid_chains; | 47 | u32 nr_invalid_chains; |
@@ -83,6 +85,7 @@ struct hists { | |||
83 | struct rb_root entries; | 85 | struct rb_root entries; |
84 | struct rb_root entries_collapsed; | 86 | struct rb_root entries_collapsed; |
85 | u64 nr_entries; | 87 | u64 nr_entries; |
88 | u64 nr_non_filtered_entries; | ||
86 | const struct thread *thread_filter; | 89 | const struct thread *thread_filter; |
87 | const struct dso *dso_filter; | 90 | const struct dso *dso_filter; |
88 | const char *uid_filter_str; | 91 | const char *uid_filter_str; |