From dd464345f330c1103f93daad309e8b44845e96cf Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Thu, 4 Oct 2012 21:49:36 +0900 Subject: perf diff: Refactor diff displacement possition info Moving the position calculation into the diff command, so the position as prepared inside struct hist_entry data and there's no need to compute in the output display path. Removing 'displacement' from struct perf_hpp as it is no longer needed. Signed-off-by: Jiri Olsa Cc: Corey Ashford Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1349354994-17853-3-git-send-email-namhyung@kernel.org Signed-off-by: Namhyung Kim Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/hist.c | 8 +++++--- tools/perf/ui/stdio/hist.c | 17 +++-------------- 2 files changed, 8 insertions(+), 17 deletions(-) (limited to 'tools/perf/ui') diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index e3f8cd46e7d..55b9ca8f084 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -244,13 +244,15 @@ static int hpp__width_displ(struct perf_hpp *hpp __maybe_unused) } static int hpp__entry_displ(struct perf_hpp *hpp, - struct hist_entry *he __maybe_unused) + struct hist_entry *he) { + struct hist_entry *pair = he->pair; + long displacement = pair ? pair->position - he->position : 0; const char *fmt = symbol_conf.field_sep ? "%s" : "%6.6s"; char buf[32] = " "; - if (hpp->displacement) - scnprintf(buf, sizeof(buf), "%+4ld", hpp->displacement); + if (displacement) + scnprintf(buf, sizeof(buf), "%+4ld", displacement); return scnprintf(hpp->buf, hpp->size, fmt, buf); } diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 882461a4283..d7405f064e8 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -308,7 +308,7 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he, static int hist_entry__fprintf(struct hist_entry *he, size_t size, struct hists *hists, struct hists *pair_hists, - long displacement, u64 total_period, FILE *fp) + u64 total_period, FILE *fp) { char bf[512]; int ret; @@ -316,7 +316,6 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, .buf = bf, .size = size, .total_period = total_period, - .displacement = displacement, .ptr = pair_hists, }; bool color = !symbol_conf.field_sep; @@ -337,15 +336,13 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, } size_t hists__fprintf(struct hists *hists, struct hists *pair, - bool show_displacement, bool show_header, int max_rows, + bool show_header, int max_rows, int max_cols, FILE *fp) { struct sort_entry *se; struct rb_node *nd; size_t ret = 0; u64 total_period; - unsigned long position = 1; - long displacement = 0; unsigned int width; const char *sep = symbol_conf.field_sep; const char *col_width = symbol_conf.col_width_list_str; @@ -449,15 +446,7 @@ print_entries: if (h->filtered) continue; - if (show_displacement) { - if (h->pair != NULL) - displacement = ((long)h->pair->position - - (long)position); - else - displacement = 0; - ++position; - } - ret += hist_entry__fprintf(h, max_cols, hists, pair, displacement, + ret += hist_entry__fprintf(h, max_cols, hists, pair, total_period, fp); if (max_rows && ++nr_rows >= max_rows) -- cgit v1.2.3-70-g09d2