aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-diff.c
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 /tools/perf/builtin-diff.c
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>
Diffstat (limited to 'tools/perf/builtin-diff.c')
-rw-r--r--tools/perf/builtin-diff.c30
1 files changed, 22 insertions, 8 deletions
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,