const char *metricgroup_name)
{
struct outstate *os = ctx;
- int n;
if (!metricgroup_name) {
__new_line_std(config, os);
return;
}
- n = fprintf(config->output, " %*s", EVNAME_LEN, metricgroup_name);
-
- fprintf(config->output, "%*s", MGROUP_LEN + config->unit_width + 2 - n, "");
+ fprintf(config->output, " %*s", config->metric_only_len, metricgroup_name);
}
static void print_metric_only(struct perf_stat_config *config,
struct outstate *os = ctx;
FILE *out = os->fh;
char str[1024];
- unsigned mlen = config->metric_only_len;
+ unsigned mlen;
const char *color = metric_threshold_classify__color(thresh);
+ int olen;
- if (!unit)
- unit = "";
- if (mlen < strlen(unit))
- mlen = strlen(unit) + 1;
+ if (!unit) {
+ os->first = false;
+ return;
+ }
- if (color)
- mlen += strlen(color) + sizeof(PERF_COLOR_RESET) - 1;
+ mlen = max_t(unsigned, strlen(unit), config->metric_only_len);
+ olen = snprintf(str, sizeof(str), fmt ?: "", val);
color_snprintf(str, sizeof(str), color ?: "", fmt ?: "", val);
- fprintf(out, "%*s ", mlen, str);
+ fprintf(out, "%*s%s", max_t(int, mlen - olen, 1), "", str);
os->first = false;
}