mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 23:20:05 +00:00
perf hists browser: Convert hpp helpers to a function
The hpp helpers do same job for each field so it was implemented as macro in order to access those fields easily. But it gets cumbersome to maintain a large function in a macro as the function grows. Factor it out to a function with a little helper macro to access field. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1358845787-1350-8-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
4fb71074a5
commit
5aed9d2493
@ -567,23 +567,41 @@ static int hist_browser__show_callchain(struct hist_browser *browser,
|
|||||||
return row - first_row;
|
return row - first_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HPP__COLOR_FN(_name, _field) \
|
static int __hpp__color_fmt(struct perf_hpp *hpp, struct hist_entry *he,
|
||||||
static int hist_browser__hpp_color_ ## _name(struct perf_hpp *hpp, \
|
u64 (*get_field)(struct hist_entry *))
|
||||||
struct hist_entry *he) \
|
{
|
||||||
{ \
|
int ret;
|
||||||
struct hists *hists = he->hists; \
|
double percent = 0.0;
|
||||||
double percent = 100.0 * he->stat._field / hists->stats.total_period; \
|
struct hists *hists = he->hists;
|
||||||
*(double *)hpp->ptr = percent; \
|
|
||||||
return scnprintf(hpp->buf, hpp->size, "%6.2f%%", percent); \
|
if (hists->stats.total_period)
|
||||||
|
percent = 100.0 * get_field(he) / hists->stats.total_period;
|
||||||
|
|
||||||
|
*(double *)hpp->ptr = percent;
|
||||||
|
|
||||||
|
ret = scnprintf(hpp->buf, hpp->size, "%6.2f%%", percent);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
HPP__COLOR_FN(overhead, period)
|
#define __HPP_COLOR_PERCENT_FN(_type, _field) \
|
||||||
HPP__COLOR_FN(overhead_sys, period_sys)
|
static u64 __hpp_get_##_field(struct hist_entry *he) \
|
||||||
HPP__COLOR_FN(overhead_us, period_us)
|
{ \
|
||||||
HPP__COLOR_FN(overhead_guest_sys, period_guest_sys)
|
return he->stat._field; \
|
||||||
HPP__COLOR_FN(overhead_guest_us, period_guest_us)
|
} \
|
||||||
|
\
|
||||||
|
static int hist_browser__hpp_color_##_type(struct perf_hpp *hpp, \
|
||||||
|
struct hist_entry *he) \
|
||||||
|
{ \
|
||||||
|
return __hpp__color_fmt(hpp, he, __hpp_get_##_field); \
|
||||||
|
}
|
||||||
|
|
||||||
#undef HPP__COLOR_FN
|
__HPP_COLOR_PERCENT_FN(overhead, period)
|
||||||
|
__HPP_COLOR_PERCENT_FN(overhead_sys, period_sys)
|
||||||
|
__HPP_COLOR_PERCENT_FN(overhead_us, period_us)
|
||||||
|
__HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys)
|
||||||
|
__HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us)
|
||||||
|
|
||||||
|
#undef __HPP_COLOR_PERCENT_FN
|
||||||
|
|
||||||
void hist_browser__init_hpp(void)
|
void hist_browser__init_hpp(void)
|
||||||
{
|
{
|
||||||
@ -646,7 +664,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
|
|||||||
|
|
||||||
if (fmt->color) {
|
if (fmt->color) {
|
||||||
hpp.ptr = &percent;
|
hpp.ptr = &percent;
|
||||||
/* It will set percent for us. See HPP__COLOR_FN above. */
|
/* It will set percent for us. See __hpp__color_fmt above. */
|
||||||
width -= fmt->color(&hpp, entry);
|
width -= fmt->color(&hpp, entry);
|
||||||
|
|
||||||
ui_browser__set_percent_color(&browser->b, percent, current_entry);
|
ui_browser__set_percent_color(&browser->b, percent, current_entry);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user