diff options
Diffstat (limited to 'tools/perf/util/color.c')
| -rw-r--r-- | tools/perf/util/color.c | 22 | 
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c index 11e46da17bb..87b8672eb41 100644 --- a/tools/perf/util/color.c +++ b/tools/perf/util/color.c @@ -1,6 +1,7 @@  #include <linux/kernel.h>  #include "cache.h"  #include "color.h" +#include <math.h>  int perf_use_color_default = -1; @@ -298,10 +299,10 @@ const char *get_percent_color(double percent)  	 * entries in green - and keep the low overhead places  	 * normal:  	 */ -	if (percent >= MIN_RED) +	if (fabs(percent) >= MIN_RED)  		color = PERF_COLOR_RED;  	else { -		if (percent > MIN_GREEN) +		if (fabs(percent) > MIN_GREEN)  			color = PERF_COLOR_GREEN;  	}  	return color; @@ -318,8 +319,19 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent)  	return r;  } -int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent) +int value_color_snprintf(char *bf, size_t size, const char *fmt, double value)  { -	const char *color = get_percent_color(percent); -	return color_snprintf(bf, size, color, fmt, percent); +	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; + +	va_start(args, fmt); +	percent = va_arg(args, double); +	va_end(args); +	return value_color_snprintf(bf, size, fmt, percent);  }  | 
