Skip to content

Commit b195701

Browse files
committed
perf stat: Use field separator in the metric header
It didn't use the passed field separator (using -x option) when it prints the metric headers and always put "," between the fields. Before: $ sudo ./perf stat -a -x : --per-core -M tma_core_bound --metric-only true core,cpus,% tma_core_bound: <<<--- here: "core,cpus," but ":" expected S0-D0-C0:2:10.5: S0-D0-C1:2:14.8: S0-D0-C2:2:9.9: S0-D0-C3:2:13.2: After: $ sudo ./perf stat -a -x : --per-core -M tma_core_bound --metric-only true core:cpus:% tma_core_bound: S0-D0-C0:2:10.5: S0-D0-C1:2:15.0: S0-D0-C2:2:16.5: S0-D0-C3:2:12.5: Tested-by: Arnaldo Carvalho de Melo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent caa463b commit b195701

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tools/perf/util/stat-display.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,10 +1186,21 @@ static void print_metric_headers_std(struct perf_stat_config *config,
11861186
static void print_metric_headers_csv(struct perf_stat_config *config,
11871187
bool no_indent __maybe_unused)
11881188
{
1189+
const char *p;
1190+
11891191
if (config->interval)
1190-
fputs("time,", config->output);
1191-
if (!config->iostat_run)
1192-
fputs(aggr_header_csv[config->aggr_mode], config->output);
1192+
fprintf(config->output, "time%s", config->csv_sep);
1193+
if (config->iostat_run)
1194+
return;
1195+
1196+
p = aggr_header_csv[config->aggr_mode];
1197+
while (*p) {
1198+
if (*p == ',')
1199+
fputs(config->csv_sep, config->output);
1200+
else
1201+
fputc(*p, config->output);
1202+
p++;
1203+
}
11931204
}
11941205

11951206
static void print_metric_headers_json(struct perf_stat_config *config __maybe_unused,

0 commit comments

Comments
 (0)