aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2014-01-13 21:52:48 -0500
committerJiri Olsa <jolsa@redhat.com>2014-04-16 11:16:03 -0400
commitf2148330544a697481219b5bc34261f6dd049bfb (patch)
treeb08733dad6f875401f8751e7f7402443372d28eb /tools/perf/ui
parent1ab1fa5dfb429c533fbc791e524788cf0cc43775 (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/ui')
-rw-r--r--tools/perf/ui/browsers/hists.c35
-rw-r--r--tools/perf/ui/gtk/hists.c11
-rw-r--r--tools/perf/ui/hist.c8
3 files changed, 36 insertions, 18 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 7ec871af3f6f..7ad11477a0f5 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -769,12 +769,15 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser)
769 769
770 for (nd = browser->top; nd; nd = rb_next(nd)) { 770 for (nd = browser->top; nd; nd = rb_next(nd)) {
771 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 771 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
772 float percent = h->stat.period * 100.0 / 772 u64 total = hists__total_period(h->hists);
773 hb->hists->stats.total_period; 773 float percent = 0.0;
774 774
775 if (h->filtered) 775 if (h->filtered)
776 continue; 776 continue;
777 777
778 if (total)
779 percent = h->stat.period * 100.0 / total;
780
778 if (percent < hb->min_pcnt) 781 if (percent < hb->min_pcnt)
779 continue; 782 continue;
780 783
@@ -792,8 +795,11 @@ static struct rb_node *hists__filter_entries(struct rb_node *nd,
792{ 795{
793 while (nd != NULL) { 796 while (nd != NULL) {
794 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 797 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
795 float percent = h->stat.period * 100.0 / 798 u64 total = hists__total_period(hists);
796 hists->stats.total_period; 799 float percent = 0.0;
800
801 if (total)
802 percent = h->stat.period * 100.0 / total;
797 803
798 if (percent < min_pcnt) 804 if (percent < min_pcnt)
799 return NULL; 805 return NULL;
@@ -813,8 +819,11 @@ static struct rb_node *hists__filter_prev_entries(struct rb_node *nd,
813{ 819{
814 while (nd != NULL) { 820 while (nd != NULL) {
815 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 821 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
816 float percent = h->stat.period * 100.0 / 822 u64 total = hists__total_period(hists);
817 hists->stats.total_period; 823 float percent = 0.0;
824
825 if (total)
826 percent = h->stat.period * 100.0 / total;
818 827
819 if (!h->filtered && percent >= min_pcnt) 828 if (!h->filtered && percent >= min_pcnt)
820 return nd; 829 return nd;
@@ -1189,6 +1198,11 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size,
1189 char buf[512]; 1198 char buf[512];
1190 size_t buflen = sizeof(buf); 1199 size_t buflen = sizeof(buf);
1191 1200
1201 if (symbol_conf.filter_relative) {
1202 nr_samples = hists->stats.nr_non_filtered_samples;
1203 nr_events = hists->stats.total_non_filtered_period;
1204 }
1205
1192 if (perf_evsel__is_group_event(evsel)) { 1206 if (perf_evsel__is_group_event(evsel)) {
1193 struct perf_evsel *pos; 1207 struct perf_evsel *pos;
1194 1208
@@ -1196,8 +1210,13 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size,
1196 ev_name = buf; 1210 ev_name = buf;
1197 1211
1198 for_each_group_member(pos, evsel) { 1212 for_each_group_member(pos, evsel) {
1199 nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE]; 1213 if (symbol_conf.filter_relative) {
1200 nr_events += pos->hists.stats.total_period; 1214 nr_samples += pos->hists.stats.nr_non_filtered_samples;
1215 nr_events += pos->hists.stats.total_non_filtered_period;
1216 } else {
1217 nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE];
1218 nr_events += pos->hists.stats.total_period;
1219 }
1201 } 1220 }
1202 } 1221 }
1203 1222
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index e395ef9b0ae0..91f10f3f6dd1 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -228,12 +228,15 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
228 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { 228 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
229 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 229 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
230 GtkTreeIter iter; 230 GtkTreeIter iter;
231 float percent = h->stat.period * 100.0 / 231 u64 total = hists__total_period(h->hists);
232 hists->stats.total_period; 232 float percent = 0.0;
233 233
234 if (h->filtered) 234 if (h->filtered)
235 continue; 235 continue;
236 236
237 if (total)
238 percent = h->stat.period * 100.0 / total;
239
237 if (percent < min_pcnt) 240 if (percent < min_pcnt)
238 continue; 241 continue;
239 242
@@ -261,12 +264,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
261 } 264 }
262 265
263 if (symbol_conf.use_callchain && sort__has_sym) { 266 if (symbol_conf.use_callchain && sort__has_sym) {
264 u64 total;
265
266 if (callchain_param.mode == CHAIN_GRAPH_REL) 267 if (callchain_param.mode == CHAIN_GRAPH_REL)
267 total = h->stat.period; 268 total = h->stat.period;
268 else
269 total = hists->stats.total_period;
270 269
271 perf_gtk__add_callchain(&h->sorted_chain, store, &iter, 270 perf_gtk__add_callchain(&h->sorted_chain, store, &iter,
272 sym_col, total); 271 sym_col, total);
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 0f403b83e9d1..0912805c08f4 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -32,10 +32,10 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
32 32
33 if (fmt_percent) { 33 if (fmt_percent) {
34 double percent = 0.0; 34 double percent = 0.0;
35 u64 total = hists__total_period(hists);
35 36
36 if (hists->stats.total_period) 37 if (total)
37 percent = 100.0 * get_field(he) / 38 percent = 100.0 * get_field(he) / total;
38 hists->stats.total_period;
39 39
40 ret += hpp__call_print_fn(hpp, print_fn, fmt, percent); 40 ret += hpp__call_print_fn(hpp, print_fn, fmt, percent);
41 } else 41 } else
@@ -50,7 +50,7 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
50 50
51 list_for_each_entry(pair, &he->pairs.head, pairs.node) { 51 list_for_each_entry(pair, &he->pairs.head, pairs.node) {
52 u64 period = get_field(pair); 52 u64 period = get_field(pair);
53 u64 total = pair->hists->stats.total_period; 53 u64 total = hists__total_period(pair->hists);
54 54
55 if (!total) 55 if (!total)
56 continue; 56 continue;