diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-03-03 10:14:05 +0900 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-03-14 18:08:39 -0300 |
commit | 2f6d9009af1df0f7cba1fdfe012a089babd8c747 (patch) | |
tree | 2877d4532317b27036989960145581f42ab53779 /tools/perf/ui/hist.c | |
parent | a0088adcd651b8eb1a9ca9c7e6ebe1c2c5fb6273 (diff) |
perf ui/tui: Reuse generic __hpp__fmt() code
The __hpp__color_fmt used in the TUI code can be replace by the generic
code with small change in print_fn callback. And it also needs to move
callback function to the generic __hpp__fmt().
No functional changes intended.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1393809254-4480-5-git-send-email-namhyung@kernel.org
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 | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 0c427e5d37c7..ac39313a3f0c 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -16,15 +16,20 @@ }) int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, - u64 (*get_field)(struct hist_entry *), + hpp_field_fn get_field, hpp_callback_fn callback, const char *fmt, hpp_snprint_fn print_fn, bool fmt_percent) { - int ret; + int ret = 0; struct hists *hists = he->hists; struct perf_evsel *evsel = hists_to_evsel(hists); char *buf = hpp->buf; size_t size = hpp->size; + if (callback) { + ret = callback(hpp, true); + advance_hpp(hpp, ret); + } + if (fmt_percent) { double percent = 0.0; @@ -32,9 +37,9 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, percent = 100.0 * get_field(he) / hists->stats.total_period; - ret = hpp__call_print_fn(hpp, print_fn, fmt, percent); + ret += hpp__call_print_fn(hpp, print_fn, fmt, percent); } else - ret = hpp__call_print_fn(hpp, print_fn, fmt, get_field(he)); + ret += hpp__call_print_fn(hpp, print_fn, fmt, get_field(he)); if (perf_evsel__is_group_event(evsel)) { int prev_idx, idx_delta; @@ -94,6 +99,13 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, } } + if (callback) { + int __ret = callback(hpp, false); + + advance_hpp(hpp, __ret); + ret += __ret; + } + /* * Restore original buf and size as it's where caller expects * the result will be saved. @@ -169,7 +181,7 @@ static u64 he_get_##_field(struct hist_entry *he) \ static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ struct perf_hpp *hpp, struct hist_entry *he) \ { \ - return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \ + return __hpp__fmt(hpp, he, he_get_##_field, NULL, " %6.2f%%", \ hpp_color_scnprintf, true); \ } @@ -178,7 +190,7 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused, \ struct perf_hpp *hpp, struct hist_entry *he) \ { \ const char *fmt = symbol_conf.field_sep ? " %.2f" : " %6.2f%%"; \ - return __hpp__fmt(hpp, he, he_get_##_field, fmt, \ + return __hpp__fmt(hpp, he, he_get_##_field, NULL, fmt, \ hpp_entry_scnprintf, true); \ } @@ -192,7 +204,7 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused, \ struct perf_hpp *hpp, struct hist_entry *he) \ { \ const char *fmt = symbol_conf.field_sep ? " %"PRIu64 : " %11"PRIu64; \ - return __hpp__fmt(hpp, he, he_get_raw_##_field, fmt, \ + return __hpp__fmt(hpp, he, he_get_raw_##_field, NULL, fmt, \ hpp_entry_scnprintf, false); \ } |