Skip to content

Commit

Permalink
perf stat: Remove prefix argument in print_metric_headers()
Browse files Browse the repository at this point in the history
It always passes a whitespace to the function, thus we can just add it to the
function body.  Furthermore, it's only used in the normal output mode.

Well, actually CSV used it but it doesn't need to since we don't care about the
indentation or alignment in the CSV output.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20221123180208.2068936-6-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
namhyung authored and acmel committed Nov 24, 2022
1 parent a7ec1dd commit f123b2d
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions tools/perf/util/stat-display.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,10 +996,9 @@ static void print_no_aggr_metric(struct perf_stat_config *config,
}

static void print_metric_headers_std(struct perf_stat_config *config,
const char *prefix, bool no_indent)
bool no_indent)
{
if (prefix)
fprintf(config->output, "%s", prefix);
fputc(' ', config->output);

if (!no_indent) {
int len = aggr_header_lens[config->aggr_mode];
Expand All @@ -1012,28 +1011,23 @@ static void print_metric_headers_std(struct perf_stat_config *config,
}

static void print_metric_headers_csv(struct perf_stat_config *config,
const char *prefix,
bool no_indent __maybe_unused)
{
if (prefix)
fprintf(config->output, "%s", prefix);
if (config->interval)
fputs("time,", config->output);
if (!config->iostat_run)
fputs(aggr_header_csv[config->aggr_mode], config->output);
}

static void print_metric_headers_json(struct perf_stat_config *config,
const char *prefix __maybe_unused,
bool no_indent __maybe_unused)
{
if (config->interval)
fputs("{\"unit\" : \"sec\"}", config->output);
}

static void print_metric_headers(struct perf_stat_config *config,
struct evlist *evlist,
const char *prefix, bool no_indent)
struct evlist *evlist, bool no_indent)
{
struct evsel *counter;
struct outstate os = {
Expand All @@ -1047,11 +1041,11 @@ static void print_metric_headers(struct perf_stat_config *config,
};

if (config->json_output)
print_metric_headers_json(config, prefix, no_indent);
print_metric_headers_json(config, no_indent);
else if (config->csv_output)
print_metric_headers_csv(config, prefix, no_indent);
print_metric_headers_csv(config, no_indent);
else
print_metric_headers_std(config, prefix, no_indent);
print_metric_headers_std(config, no_indent);

if (config->iostat_run)
iostat_print_header_prefix(config);
Expand Down Expand Up @@ -1132,7 +1126,7 @@ static void print_header_interval_std(struct perf_stat_config *config,
}

if (config->metric_only)
print_metric_headers(config, evlist, " ", true);
print_metric_headers(config, evlist, true);
else
fprintf(output, " %*s %*s events\n",
COUNTS_LEN, "counts", config->unit_width, "unit");
Expand Down Expand Up @@ -1168,7 +1162,7 @@ static void print_header_std(struct perf_stat_config *config,
fprintf(output, ":\n\n");

if (config->metric_only)
print_metric_headers(config, evlist, " ", false);
print_metric_headers(config, evlist, false);
}

static void print_header_csv(struct perf_stat_config *config,
Expand All @@ -1178,7 +1172,7 @@ static void print_header_csv(struct perf_stat_config *config,
const char **argv __maybe_unused)
{
if (config->metric_only)
print_metric_headers(config, evlist, " ", true);
print_metric_headers(config, evlist, true);
}
static void print_header_json(struct perf_stat_config *config,
struct target *_target __maybe_unused,
Expand All @@ -1187,7 +1181,7 @@ static void print_header_json(struct perf_stat_config *config,
const char **argv __maybe_unused)
{
if (config->metric_only)
print_metric_headers(config, evlist, " ", true);
print_metric_headers(config, evlist, true);
}

static void print_header(struct perf_stat_config *config,
Expand Down

0 comments on commit f123b2d

Please sign in to comment.