mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
perf diff: Color the Ratio column
In
$ perf diff -c ratio
color the Ratio column using value_color_snprintf(), a new function that
operates exactly like percent_color_snprintf().
At first glance, it looks like percent_color_snprintf() can be turned
into a non-variadic function simplifying things; however, 53805ec
(perf
tools: Remove cast of non-variadic function to variadic, 2013-10-31)
explains why it needs to be a variadic function.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1388388861-7931-4-git-send-email-artagnon@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
01f10bc85f
commit
1f513b2c1e
3 changed files with 28 additions and 3 deletions
|
@ -795,6 +795,17 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt,
|
|||
scnprintf(pfmt, 20, "%%%+d.2f%%%%", dfmt->header_width - 1);
|
||||
return percent_color_snprintf(hpp->buf, hpp->size,
|
||||
pfmt, diff);
|
||||
case COMPUTE_RATIO:
|
||||
if (he->dummy)
|
||||
goto dummy_print;
|
||||
if (pair->diff.computed)
|
||||
diff = pair->diff.period_ratio;
|
||||
else
|
||||
diff = compute_ratio(he, pair);
|
||||
|
||||
scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width);
|
||||
return value_color_snprintf(hpp->buf, hpp->size,
|
||||
pfmt, diff);
|
||||
default:
|
||||
BUG_ON(1);
|
||||
}
|
||||
|
@ -809,6 +820,12 @@ static int hpp__color_delta(struct perf_hpp_fmt *fmt,
|
|||
return __hpp__color_compare(fmt, hpp, he, COMPUTE_DELTA);
|
||||
}
|
||||
|
||||
static int hpp__color_ratio(struct perf_hpp_fmt *fmt,
|
||||
struct perf_hpp *hpp, struct hist_entry *he)
|
||||
{
|
||||
return __hpp__color_compare(fmt, hpp, he, COMPUTE_RATIO);
|
||||
}
|
||||
|
||||
static void
|
||||
hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size)
|
||||
{
|
||||
|
@ -987,6 +1004,9 @@ static void data__hpp_register(struct data__file *d, int idx)
|
|||
case PERF_HPP_DIFF__DELTA:
|
||||
fmt->color = hpp__color_delta;
|
||||
break;
|
||||
case PERF_HPP_DIFF__RATIO:
|
||||
fmt->color = hpp__color_ratio;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue