Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350018
b: refs/heads/master
c: 5aed9d2
h: refs/heads/master
v: v3
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Jan 31, 2013
1 parent ebf5b73 commit 178b9a8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4fb71074a570aab9ba8a30b7a756a3c637a14c03
refs/heads/master: 5aed9d24934be5b7fec1b66cc2a5f29fab4ec11e
46 changes: 32 additions & 14 deletions trunk/tools/perf/ui/browsers/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,23 +567,41 @@ static int hist_browser__show_callchain(struct hist_browser *browser,
return row - first_row;
}

#define HPP__COLOR_FN(_name, _field) \
static int hist_browser__hpp_color_ ## _name(struct perf_hpp *hpp, \
struct hist_entry *he) \
static int __hpp__color_fmt(struct perf_hpp *hpp, struct hist_entry *he,
u64 (*get_field)(struct hist_entry *))
{
int ret;
double percent = 0.0;
struct hists *hists = he->hists;

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;
}

#define __HPP_COLOR_PERCENT_FN(_type, _field) \
static u64 __hpp_get_##_field(struct hist_entry *he) \
{ \
return he->stat._field; \
} \
\
static int hist_browser__hpp_color_##_type(struct perf_hpp *hpp, \
struct hist_entry *he) \
{ \
struct hists *hists = he->hists; \
double percent = 100.0 * he->stat._field / hists->stats.total_period; \
*(double *)hpp->ptr = percent; \
return scnprintf(hpp->buf, hpp->size, "%6.2f%%", percent); \
return __hpp__color_fmt(hpp, he, __hpp_get_##_field); \
}

HPP__COLOR_FN(overhead, period)
HPP__COLOR_FN(overhead_sys, period_sys)
HPP__COLOR_FN(overhead_us, period_us)
HPP__COLOR_FN(overhead_guest_sys, period_guest_sys)
HPP__COLOR_FN(overhead_guest_us, period_guest_us)
__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_FN
#undef __HPP_COLOR_PERCENT_FN

void hist_browser__init_hpp(void)
{
Expand Down Expand Up @@ -646,7 +664,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,

if (fmt->color) {
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);

ui_browser__set_percent_color(&browser->b, percent, current_entry);
Expand Down

0 comments on commit 178b9a8

Please sign in to comment.