diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-10-05 10:44:45 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-05 13:13:36 -0400 |
commit | ed279da2fc9774b4c0dc9fd513fa89a11cae3f56 (patch) | |
tree | cf7f38620d7e7ede1976b999ae613c35db959fc8 /tools/perf/builtin-diff.c | |
parent | 61949b212e7f6f8f31891236ba24033f9b7af8c3 (diff) |
perf diff: Add -F option to display formula for computation
Adding -F option to display the formula for specified computation.
This is mainly to facilitate debugging, but can be useful anyway.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1349448287-18919-7-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-diff.c')
-rw-r--r-- | tools/perf/builtin-diff.c | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 2411dd18c556..dd9c064514f2 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -25,6 +25,7 @@ static char diff__default_sort_order[] = "dso,symbol"; | |||
25 | static bool force; | 25 | static bool force; |
26 | static bool show_displacement; | 26 | static bool show_displacement; |
27 | static bool show_period; | 27 | static bool show_period; |
28 | static bool show_formula; | ||
28 | static bool show_baseline_only; | 29 | static bool show_baseline_only; |
29 | static bool sort_compute; | 30 | static bool sort_compute; |
30 | 31 | ||
@@ -190,6 +191,62 @@ s64 perf_diff__compute_wdiff(struct hist_entry *he) | |||
190 | return he->diff.wdiff; | 191 | return he->diff.wdiff; |
191 | } | 192 | } |
192 | 193 | ||
194 | static int formula_delta(struct hist_entry *he, char *buf, size_t size) | ||
195 | { | ||
196 | struct hist_entry *pair = he->pair; | ||
197 | |||
198 | if (!pair) | ||
199 | return -1; | ||
200 | |||
201 | return scnprintf(buf, size, | ||
202 | "(%" PRIu64 " * 100 / %" PRIu64 ") - " | ||
203 | "(%" PRIu64 " * 100 / %" PRIu64 ")", | ||
204 | he->stat.period, he->hists->stats.total_period, | ||
205 | pair->stat.period, pair->hists->stats.total_period); | ||
206 | } | ||
207 | |||
208 | static int formula_ratio(struct hist_entry *he, char *buf, size_t size) | ||
209 | { | ||
210 | struct hist_entry *pair = he->pair; | ||
211 | double new_period = he->stat.period; | ||
212 | double old_period = pair ? pair->stat.period : 0; | ||
213 | |||
214 | if (!pair) | ||
215 | return -1; | ||
216 | |||
217 | return scnprintf(buf, size, "%.0F / %.0F", new_period, old_period); | ||
218 | } | ||
219 | |||
220 | static int formula_wdiff(struct hist_entry *he, char *buf, size_t size) | ||
221 | { | ||
222 | struct hist_entry *pair = he->pair; | ||
223 | u64 new_period = he->stat.period; | ||
224 | u64 old_period = pair ? pair->stat.period : 0; | ||
225 | |||
226 | if (!pair) | ||
227 | return -1; | ||
228 | |||
229 | return scnprintf(buf, size, | ||
230 | "(%" PRIu64 " * " "%" PRId64 ") - (%" PRIu64 " * " "%" PRId64 ")", | ||
231 | new_period, compute_wdiff_w2, old_period, compute_wdiff_w1); | ||
232 | } | ||
233 | |||
234 | int perf_diff__formula(char *buf, size_t size, struct hist_entry *he) | ||
235 | { | ||
236 | switch (compute) { | ||
237 | case COMPUTE_DELTA: | ||
238 | return formula_delta(he, buf, size); | ||
239 | case COMPUTE_RATIO: | ||
240 | return formula_ratio(he, buf, size); | ||
241 | case COMPUTE_WEIGHTED_DIFF: | ||
242 | return formula_wdiff(he, buf, size); | ||
243 | default: | ||
244 | BUG_ON(1); | ||
245 | } | ||
246 | |||
247 | return -1; | ||
248 | } | ||
249 | |||
193 | static int hists__add_entry(struct hists *self, | 250 | static int hists__add_entry(struct hists *self, |
194 | struct addr_location *al, u64 period) | 251 | struct addr_location *al, u64 period) |
195 | { | 252 | { |
@@ -543,6 +600,8 @@ static const struct option options[] = { | |||
543 | setup_compute), | 600 | setup_compute), |
544 | OPT_BOOLEAN('p', "period", &show_period, | 601 | OPT_BOOLEAN('p', "period", &show_period, |
545 | "Show period values."), | 602 | "Show period values."), |
603 | OPT_BOOLEAN('F', "formula", &show_formula, | ||
604 | "Show formula."), | ||
546 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 605 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
547 | "dump raw trace in ASCII"), | 606 | "dump raw trace in ASCII"), |
548 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | 607 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), |
@@ -571,7 +630,10 @@ static void ui_init(void) | |||
571 | /* No overhead column. */ | 630 | /* No overhead column. */ |
572 | perf_hpp__column_enable(PERF_HPP__OVERHEAD, false); | 631 | perf_hpp__column_enable(PERF_HPP__OVERHEAD, false); |
573 | 632 | ||
574 | /* Display baseline/delta/ratio/displacement/periods columns. */ | 633 | /* |
634 | * Display baseline/delta/ratio/displacement/ | ||
635 | * formula/periods columns. | ||
636 | */ | ||
575 | perf_hpp__column_enable(PERF_HPP__BASELINE, true); | 637 | perf_hpp__column_enable(PERF_HPP__BASELINE, true); |
576 | 638 | ||
577 | switch (compute) { | 639 | switch (compute) { |
@@ -591,6 +653,9 @@ static void ui_init(void) | |||
591 | if (show_displacement) | 653 | if (show_displacement) |
592 | perf_hpp__column_enable(PERF_HPP__DISPL, true); | 654 | perf_hpp__column_enable(PERF_HPP__DISPL, true); |
593 | 655 | ||
656 | if (show_formula) | ||
657 | perf_hpp__column_enable(PERF_HPP__FORMULA, true); | ||
658 | |||
594 | if (show_period) { | 659 | if (show_period) { |
595 | perf_hpp__column_enable(PERF_HPP__PERIOD, true); | 660 | perf_hpp__column_enable(PERF_HPP__PERIOD, true); |
596 | perf_hpp__column_enable(PERF_HPP__PERIOD_BASELINE, true); | 661 | perf_hpp__column_enable(PERF_HPP__PERIOD_BASELINE, true); |