From: Namhyung Kim Date: Fri, 28 Jun 2024 00:06:04 +0000 (-0700) Subject: perf stat: Use field separator in the metric header X-Git-Tag: v6.11-rc1~130^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b195701e9f0f78f30d500ada246b3693f26e11ee;p=thirdparty%2Flinux.git 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 Link: https://lore.kernel.org/r/20240628000604.1296808-2-namhyung@kernel.org Signed-off-by: Namhyung Kim --- diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 186305fd2d0ef..c38bcb6f4c78e 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -1186,10 +1186,21 @@ static void print_metric_headers_std(struct perf_stat_config *config, static void print_metric_headers_csv(struct perf_stat_config *config, bool no_indent __maybe_unused) { + const char *p; + if (config->interval) - fputs("time,", config->output); - if (!config->iostat_run) - fputs(aggr_header_csv[config->aggr_mode], config->output); + fprintf(config->output, "time%s", config->csv_sep); + if (config->iostat_run) + return; + + p = aggr_header_csv[config->aggr_mode]; + while (*p) { + if (*p == ',') + fputs(config->csv_sep, config->output); + else + fputc(*p, config->output); + p++; + } } static void print_metric_headers_json(struct perf_stat_config *config __maybe_unused,