Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350019
b: refs/heads/master
c: 843985e
h: refs/heads/master
i:
  350017: ebf5b73
  350015: 6dfbc2c
v: v3
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Jan 31, 2013
1 parent 178b9a8 commit a9f59e6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 22 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: 5aed9d24934be5b7fec1b66cc2a5f29fab4ec11e
refs/heads/master: 843985e953ddcc3d57a62641b377c8d3222859e2
68 changes: 47 additions & 21 deletions trunk/tools/perf/ui/gtk/hists.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,58 @@

#define MAX_COLUMNS 32

#define HPP__COLOR_FN(_name, _field) \
static int perf_gtk__hpp_color_ ## _name(struct perf_hpp *hpp, \
struct hist_entry *he) \
static int perf_gtk__percent_color_snprintf(char *buf, size_t size,
double percent)
{
int ret = 0;
const char *markup;

markup = perf_gtk__get_percent_color(percent);
if (markup)
ret += scnprintf(buf, size, markup);

ret += scnprintf(buf + ret, size - ret, "%6.2f%%", percent);

if (markup)
ret += scnprintf(buf + ret, size - ret, "</span>");

return ret;
}


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;

ret = perf_gtk__percent_color_snprintf(hpp->buf, hpp->size, percent);
return ret;
}

#define __HPP_COLOR_PERCENT_FN(_type, _field) \
static u64 he_get_##_field(struct hist_entry *he) \
{ \
struct hists *hists = he->hists; \
double percent = 100.0 * he->stat._field / hists->stats.total_period; \
const char *markup; \
int ret = 0; \
\
markup = perf_gtk__get_percent_color(percent); \
if (markup) \
ret += scnprintf(hpp->buf, hpp->size, "%s", markup); \
ret += scnprintf(hpp->buf + ret, hpp->size - ret, "%6.2f%%", percent); \
if (markup) \
ret += scnprintf(hpp->buf + ret, hpp->size - ret, "</span>"); \
return he->stat._field; \
} \
\
return ret; \
static int perf_gtk__hpp_color_##_type(struct perf_hpp *hpp, \
struct hist_entry *he) \
{ \
return __hpp__color_fmt(hpp, he, he_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 perf_gtk__init_hpp(void)
Expand Down

0 comments on commit a9f59e6

Please sign in to comment.