diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-10-05 10:44:42 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-05 13:08:54 -0400 |
commit | 96c47f19846742bdfa3c153c8d26ccca5945586b (patch) | |
tree | 209bbd497e4ddc814718fd8963abd615850e412d /tools/perf/ui/hist.c | |
parent | 7aaf6b35512382329c5b2dd46b42f2bf12a5fff0 (diff) |
perf diff: Add option to sort entries based on diff computation
Adding support to sort hist entries based on the outcome of selected
computation. It's now possible to specify '+' as a first character of
'-c' option value to make such sort.
Example:
$ perf diff -c ratio -b
# Event 'cache-misses'
#
# Baseline Ratio Shared Object Symbol
# ........ .............. ................. ................................
#
19.64% 0.69 [kernel.kallsyms] [k] clear_page
0.30% 0.17 [kernel.kallsyms] [k] mm_alloc
0.04% 0.20 [kernel.kallsyms] [k] kmem_cache_alloc
$ perf diff -c +ratio -b
# Event 'cache-misses'
#
# Baseline Ratio Shared Object Symbol
# ........ .............. ................. ................................
#
19.64% 0.69 [kernel.kallsyms] [k] clear_page
0.04% 0.20 [kernel.kallsyms] [k] kmem_cache_alloc
0.30% 0.17 [kernel.kallsyms] [k] mm_alloc
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-4-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/hist.c')
-rw-r--r-- | tools/perf/ui/hist.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 1b633a4b5c45..659f2a25e997 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -242,24 +242,15 @@ static int hpp__width_delta(struct perf_hpp *hpp __maybe_unused) | |||
242 | 242 | ||
243 | static int hpp__entry_delta(struct perf_hpp *hpp, struct hist_entry *he) | 243 | static int hpp__entry_delta(struct perf_hpp *hpp, struct hist_entry *he) |
244 | { | 244 | { |
245 | struct hist_entry *pair = he->pair; | ||
246 | struct hists *pair_hists = pair ? pair->hists : NULL; | ||
247 | struct hists *hists = he->hists; | ||
248 | u64 old_total, new_total; | ||
249 | double old_percent = 0, new_percent = 0; | ||
250 | double diff; | ||
251 | const char *fmt = symbol_conf.field_sep ? "%s" : "%7.7s"; | 245 | const char *fmt = symbol_conf.field_sep ? "%s" : "%7.7s"; |
252 | char buf[32] = " "; | 246 | char buf[32] = " "; |
247 | double diff; | ||
253 | 248 | ||
254 | old_total = pair_hists ? pair_hists->stats.total_period : 0; | 249 | if (he->diff.computed) |
255 | if (old_total > 0 && pair) | 250 | diff = he->diff.period_ratio_delta; |
256 | old_percent = 100.0 * pair->stat.period / old_total; | 251 | else |
257 | 252 | diff = perf_diff__compute_delta(he); | |
258 | new_total = hists->stats.total_period; | ||
259 | if (new_total > 0) | ||
260 | new_percent = 100.0 * he->stat.period / new_total; | ||
261 | 253 | ||
262 | diff = new_percent - old_percent; | ||
263 | if (fabs(diff) >= 0.01) | 254 | if (fabs(diff) >= 0.01) |
264 | scnprintf(buf, sizeof(buf), "%+4.2F%%", diff); | 255 | scnprintf(buf, sizeof(buf), "%+4.2F%%", diff); |
265 | 256 | ||
@@ -280,12 +271,14 @@ static int hpp__width_ratio(struct perf_hpp *hpp __maybe_unused) | |||
280 | 271 | ||
281 | static int hpp__entry_ratio(struct perf_hpp *hpp, struct hist_entry *he) | 272 | static int hpp__entry_ratio(struct perf_hpp *hpp, struct hist_entry *he) |
282 | { | 273 | { |
283 | struct hist_entry *pair = he->pair; | ||
284 | double new_period = he->stat.period; | ||
285 | double old_period = pair ? pair->stat.period : 0; | ||
286 | double ratio = pair ? new_period / old_period : 0; | ||
287 | const char *fmt = symbol_conf.field_sep ? "%s" : "%14s"; | 274 | const char *fmt = symbol_conf.field_sep ? "%s" : "%14s"; |
288 | char buf[32] = " "; | 275 | char buf[32] = " "; |
276 | double ratio; | ||
277 | |||
278 | if (he->diff.computed) | ||
279 | ratio = he->diff.period_ratio; | ||
280 | else | ||
281 | ratio = perf_diff__compute_ratio(he); | ||
289 | 282 | ||
290 | if (ratio > 0.0) | 283 | if (ratio > 0.0) |
291 | scnprintf(buf, sizeof(buf), "%+14.6F", ratio); | 284 | scnprintf(buf, sizeof(buf), "%+14.6F", ratio); |