aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2014-02-06 22:06:07 -0500
committerJiri Olsa <jolsa@redhat.com>2014-04-16 11:16:03 -0400
commit8810f6ced73556c1a63b6269a6cdad8d630aaaf0 (patch)
tree44357b32b7388716d983f037223cc38a27feb905
parent33db4568e1f41efe6d0e4695483f968fc1135bf3 (diff)
perf diff: Add --percentage option
The --percentage option is for controlling overhead percentage displayed. It can only receive either of "relative" or "absolute" and affects -c delta output only. For more information, please see previous commit same thing done to "perf report". Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1397145720-8063-5-git-send-email-namhyung@kernel.org Signed-off-by: Jiri Olsa <jolsa@redhat.com>
-rw-r--r--tools/perf/Documentation/perf-diff.txt21
-rw-r--r--tools/perf/builtin-diff.c30
2 files changed, 40 insertions, 11 deletions
diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt
index fdfceee0ffd0..fbfa1192923c 100644
--- a/tools/perf/Documentation/perf-diff.txt
+++ b/tools/perf/Documentation/perf-diff.txt
@@ -33,17 +33,20 @@ OPTIONS
33-d:: 33-d::
34--dsos=:: 34--dsos=::
35 Only consider symbols in these dsos. CSV that understands 35 Only consider symbols in these dsos. CSV that understands
36 file://filename entries. 36 file://filename entries. This option will affect the percentage
37 of the Baseline/Delta column. See --percentage for more info.
37 38
38-C:: 39-C::
39--comms=:: 40--comms=::
40 Only consider symbols in these comms. CSV that understands 41 Only consider symbols in these comms. CSV that understands
41 file://filename entries. 42 file://filename entries. This option will affect the percentage
43 of the Baseline/Delta column. See --percentage for more info.
42 44
43-S:: 45-S::
44--symbols=:: 46--symbols=::
45 Only consider these symbols. CSV that understands 47 Only consider these symbols. CSV that understands
46 file://filename entries. 48 file://filename entries. This option will affect the percentage
49 of the Baseline/Delta column. See --percentage for more info.
47 50
48-s:: 51-s::
49--sort=:: 52--sort=::
@@ -89,6 +92,14 @@ OPTIONS
89--order:: 92--order::
90 Specify compute sorting column number. 93 Specify compute sorting column number.
91 94
95--percentage::
96 Determine how to display the overhead percentage of filtered entries.
97 Filters can be applied by --comms, --dsos and/or --symbols options.
98
99 "relative" means it's relative to filtered entries only so that the
100 sum of shown entries will be always 100%. "absolute" means it retains
101 the original value before and after the filter is applied.
102
92COMPARISON 103COMPARISON
93---------- 104----------
94The comparison is governed by the baseline file. The baseline perf.data 105The comparison is governed by the baseline file. The baseline perf.data
@@ -157,6 +168,10 @@ with:
157 - period_percent being the % of the hist entry period value within 168 - period_percent being the % of the hist entry period value within
158 single data file 169 single data file
159 170
171 - with filtering by -C, -d and/or -S, period_percent might be changed
172 relative to how entries are filtered. Use --percentage=absolute to
173 prevent such fluctuation.
174
160ratio 175ratio
161~~~~~ 176~~~~~
162If specified the 'Ratio' column is displayed with value 'r' computed as: 177If specified the 'Ratio' column is displayed with value 'r' computed as:
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 204fffe22532..c903fe13c173 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -220,7 +220,8 @@ static int setup_compute(const struct option *opt, const char *str,
220 220
221static double period_percent(struct hist_entry *he, u64 period) 221static double period_percent(struct hist_entry *he, u64 period)
222{ 222{
223 u64 total = he->hists->stats.total_period; 223 u64 total = hists__total_period(he->hists);
224
224 return (period * 100.0) / total; 225 return (period * 100.0) / total;
225} 226}
226 227
@@ -259,11 +260,18 @@ static s64 compute_wdiff(struct hist_entry *he, struct hist_entry *pair)
259static int formula_delta(struct hist_entry *he, struct hist_entry *pair, 260static int formula_delta(struct hist_entry *he, struct hist_entry *pair,
260 char *buf, size_t size) 261 char *buf, size_t size)
261{ 262{
263 u64 he_total = he->hists->stats.total_period;
264 u64 pair_total = pair->hists->stats.total_period;
265
266 if (symbol_conf.filter_relative) {
267 he_total = he->hists->stats.total_non_filtered_period;
268 pair_total = pair->hists->stats.total_non_filtered_period;
269 }
262 return scnprintf(buf, size, 270 return scnprintf(buf, size,
263 "(%" PRIu64 " * 100 / %" PRIu64 ") - " 271 "(%" PRIu64 " * 100 / %" PRIu64 ") - "
264 "(%" PRIu64 " * 100 / %" PRIu64 ")", 272 "(%" PRIu64 " * 100 / %" PRIu64 ")",
265 pair->stat.period, pair->hists->stats.total_period, 273 pair->stat.period, pair_total,
266 he->stat.period, he->hists->stats.total_period); 274 he->stat.period, he_total);
267} 275}
268 276
269static int formula_ratio(struct hist_entry *he, struct hist_entry *pair, 277static int formula_ratio(struct hist_entry *he, struct hist_entry *pair,
@@ -327,15 +335,16 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused,
327 return -1; 335 return -1;
328 } 336 }
329 337
330 if (al.filtered)
331 return 0;
332
333 if (hists__add_entry(&evsel->hists, &al, sample->period, 338 if (hists__add_entry(&evsel->hists, &al, sample->period,
334 sample->weight, sample->transaction)) { 339 sample->weight, sample->transaction)) {
335 pr_warning("problem incrementing symbol period, skipping event\n"); 340 pr_warning("problem incrementing symbol period, skipping event\n");
336 return -1; 341 return -1;
337 } 342 }
338 343
344 if (al.filtered == 0) {
345 evsel->hists.stats.total_non_filtered_period += sample->period;
346 evsel->hists.nr_non_filtered_entries++;
347 }
339 evsel->hists.stats.total_period += sample->period; 348 evsel->hists.stats.total_period += sample->period;
340 return 0; 349 return 0;
341} 350}
@@ -565,7 +574,9 @@ static void hists__compute_resort(struct hists *hists)
565 next = rb_first(root); 574 next = rb_first(root);
566 575
567 hists->nr_entries = 0; 576 hists->nr_entries = 0;
577 hists->nr_non_filtered_entries = 0;
568 hists->stats.total_period = 0; 578 hists->stats.total_period = 0;
579 hists->stats.total_non_filtered_period = 0;
569 hists__reset_col_len(hists); 580 hists__reset_col_len(hists);
570 581
571 while (next != NULL) { 582 while (next != NULL) {
@@ -732,13 +743,16 @@ static const struct option options[] = {
732 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", 743 OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
733 "Look for files with symbols relative to this directory"), 744 "Look for files with symbols relative to this directory"),
734 OPT_UINTEGER('o', "order", &sort_compute, "Specify compute sorting."), 745 OPT_UINTEGER('o', "order", &sort_compute, "Specify compute sorting."),
746 OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
747 "How to display percentage of filtered entries", parse_filter_percentage),
735 OPT_END() 748 OPT_END()
736}; 749};
737 750
738static double baseline_percent(struct hist_entry *he) 751static double baseline_percent(struct hist_entry *he)
739{ 752{
740 struct hists *hists = he->hists; 753 u64 total = hists__total_period(he->hists);
741 return 100.0 * he->stat.period / hists->stats.total_period; 754
755 return 100.0 * he->stat.period / total;
742} 756}
743 757
744static int hpp__color_baseline(struct perf_hpp_fmt *fmt, 758static int hpp__color_baseline(struct perf_hpp_fmt *fmt,