aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/hist.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-10-05 10:44:41 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-10-05 13:06:54 -0400
commit7aaf6b35512382329c5b2dd46b42f2bf12a5fff0 (patch)
treea0523500216e2224547bfe4c3e49630826fcbcf0 /tools/perf/ui/hist.c
parenta06d143e7cfaa10626f3ad0127a9b9169f900add (diff)
perf diff: Add ratio computation way to compare hist entries
Adding -c option to select computation method with the current 'Delta' computation as default. Current possible values are of this option are: 'delta' and 'ratio'. Adding 'ratio' as new computation way to compare hist entries. If specified the 'Ratio' column is displayed with value 'r' computed as: r = A->period / B->period with: - A/B being matching hist entry from first/second file specified (or perf.data/perf.data.old) respectively. - period being the hist entry period value 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-3-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.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index f5a1e4f65263..1b633a4b5c45 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -266,6 +266,33 @@ static int hpp__entry_delta(struct perf_hpp *hpp, struct hist_entry *he)
266 return scnprintf(hpp->buf, hpp->size, fmt, buf); 266 return scnprintf(hpp->buf, hpp->size, fmt, buf);
267} 267}
268 268
269static int hpp__header_ratio(struct perf_hpp *hpp)
270{
271 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
272
273 return scnprintf(hpp->buf, hpp->size, fmt, "Ratio");
274}
275
276static int hpp__width_ratio(struct perf_hpp *hpp __maybe_unused)
277{
278 return 14;
279}
280
281static int hpp__entry_ratio(struct perf_hpp *hpp, struct hist_entry *he)
282{
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";
288 char buf[32] = " ";
289
290 if (ratio > 0.0)
291 scnprintf(buf, sizeof(buf), "%+14.6F", ratio);
292
293 return scnprintf(hpp->buf, hpp->size, fmt, buf);
294}
295
269static int hpp__header_displ(struct perf_hpp *hpp) 296static int hpp__header_displ(struct perf_hpp *hpp)
270{ 297{
271 return scnprintf(hpp->buf, hpp->size, "Displ."); 298 return scnprintf(hpp->buf, hpp->size, "Displ.");
@@ -311,6 +338,7 @@ struct perf_hpp_fmt perf_hpp__format[] = {
311 { .cond = false, HPP__PRINT_FNS(samples) }, 338 { .cond = false, HPP__PRINT_FNS(samples) },
312 { .cond = false, HPP__PRINT_FNS(period) }, 339 { .cond = false, HPP__PRINT_FNS(period) },
313 { .cond = false, HPP__PRINT_FNS(delta) }, 340 { .cond = false, HPP__PRINT_FNS(delta) },
341 { .cond = false, HPP__PRINT_FNS(ratio) },
314 { .cond = false, HPP__PRINT_FNS(displ) } 342 { .cond = false, HPP__PRINT_FNS(displ) }
315}; 343};
316 344