aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/hist.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-11-28 08:52:40 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-12-09 06:46:06 -0500
commit05472daa4d8ab88a071bfcaa3bb47473e4071848 (patch)
treecf86ff56669b9967fed53839b5e6f4e6cd820a57 /tools/perf/ui/hist.c
parentfa283ada1606e687641dc2b157d66ef0f9c9aa8a (diff)
perf diff: Change compute methods to work with pair directly
Changing compute methods to operate over hist entry and its pair directly. This makes the code more obvious and readable, instead of all time checking for pair being != NULL. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Namhyung Kim <namhyung@kernel.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/1354110769-2998-6-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.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 6e639b506829..108e5ed67621 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -268,14 +268,18 @@ static int hpp__width_delta(struct perf_hpp *hpp __maybe_unused)
268 268
269static int hpp__entry_delta(struct perf_hpp *hpp, struct hist_entry *he) 269static int hpp__entry_delta(struct perf_hpp *hpp, struct hist_entry *he)
270{ 270{
271 struct hist_entry *pair = hist_entry__next_pair(he);
271 const char *fmt = symbol_conf.field_sep ? "%s" : "%7.7s"; 272 const char *fmt = symbol_conf.field_sep ? "%s" : "%7.7s";
272 char buf[32] = " "; 273 char buf[32] = " ";
273 double diff; 274 double diff = 0.0;
274 275
275 if (he->diff.computed) 276 if (pair) {
276 diff = he->diff.period_ratio_delta; 277 if (he->diff.computed)
277 else 278 diff = he->diff.period_ratio_delta;
278 diff = perf_diff__compute_delta(he); 279 else
280 diff = perf_diff__compute_delta(he, pair);
281 } else
282 diff = perf_diff__period_percent(he, he->stat.period);
279 283
280 if (fabs(diff) >= 0.01) 284 if (fabs(diff) >= 0.01)
281 scnprintf(buf, sizeof(buf), "%+4.2F%%", diff); 285 scnprintf(buf, sizeof(buf), "%+4.2F%%", diff);
@@ -297,14 +301,17 @@ static int hpp__width_ratio(struct perf_hpp *hpp __maybe_unused)
297 301
298static int hpp__entry_ratio(struct perf_hpp *hpp, struct hist_entry *he) 302static int hpp__entry_ratio(struct perf_hpp *hpp, struct hist_entry *he)
299{ 303{
304 struct hist_entry *pair = hist_entry__next_pair(he);
300 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s"; 305 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
301 char buf[32] = " "; 306 char buf[32] = " ";
302 double ratio; 307 double ratio = 0.0;
303 308
304 if (he->diff.computed) 309 if (pair) {
305 ratio = he->diff.period_ratio; 310 if (he->diff.computed)
306 else 311 ratio = he->diff.period_ratio;
307 ratio = perf_diff__compute_ratio(he); 312 else
313 ratio = perf_diff__compute_ratio(he, pair);
314 }
308 315
309 if (ratio > 0.0) 316 if (ratio > 0.0)
310 scnprintf(buf, sizeof(buf), "%+14.6F", ratio); 317 scnprintf(buf, sizeof(buf), "%+14.6F", ratio);
@@ -326,14 +333,17 @@ static int hpp__width_wdiff(struct perf_hpp *hpp __maybe_unused)
326 333
327static int hpp__entry_wdiff(struct perf_hpp *hpp, struct hist_entry *he) 334static int hpp__entry_wdiff(struct perf_hpp *hpp, struct hist_entry *he)
328{ 335{
336 struct hist_entry *pair = hist_entry__next_pair(he);
329 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s"; 337 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
330 char buf[32] = " "; 338 char buf[32] = " ";
331 s64 wdiff; 339 s64 wdiff = 0;
332 340
333 if (he->diff.computed) 341 if (pair) {
334 wdiff = he->diff.wdiff; 342 if (he->diff.computed)
335 else 343 wdiff = he->diff.wdiff;
336 wdiff = perf_diff__compute_wdiff(he); 344 else
345 wdiff = perf_diff__compute_wdiff(he, pair);
346 }
337 347
338 if (wdiff != 0) 348 if (wdiff != 0)
339 scnprintf(buf, sizeof(buf), "%14ld", wdiff); 349 scnprintf(buf, sizeof(buf), "%14ld", wdiff);