summaryrefslogtreecommitdiff
path: root/tools/perf/util/color.c
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2013-12-30 13:04:20 +0530
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-01-13 11:37:17 -0300
commit1f513b2c1e8a2008b8ab767fdb6fa6c154591ed3 (patch)
treea53d0f8f29a86b8a2e2043379d06887351a07d02 /tools/perf/util/color.c
parent01f10bc85f538cd681d0a3338b97a33f308d944b (diff)
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>
Diffstat (limited to 'tools/perf/util/color.c')
-rw-r--r--tools/perf/util/color.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index 8cda46c43e74..87b8672eb413 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -319,15 +319,19 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent)
return r;
}
+int value_color_snprintf(char *bf, size_t size, const char *fmt, double value)
+{
+ const char *color = get_percent_color(value);
+ return color_snprintf(bf, size, color, fmt, value);
+}
+
int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...)
{
va_list args;
double percent;
- const char *color;
va_start(args, fmt);
percent = va_arg(args, double);
va_end(args);
- color = get_percent_color(percent);
- return color_snprintf(bf, size, color, fmt, percent);
+ return value_color_snprintf(bf, size, fmt, percent);
}