diff options
author | Namhyung Kim <[email protected]> | 2022-11-07 13:33:09 -0800 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2022-11-14 13:21:19 -0300 |
commit | f4e55f88da923f39f0b76edc3da3c52d0b72d429 (patch) | |
tree | 7c7ac1c477aa2d238936a470ba0574199f5f706b | |
parent | 81a02c6577ecfee7056ccafbd028984d0d670c0c (diff) |
perf stat: Move common code in print_metric_headers()
The struct perf_stat_output_ctx is set in a loop with the same values.
Move the code out of the loop and keep the loop minimal.
Signed-off-by: Namhyung Kim <[email protected]>
Acked-by: Ian Rogers <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: James Clark <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Xing Zhengjun <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r-- | tools/perf/util/stat-display.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index ccb804546d5a..173f4715189c 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -835,11 +835,16 @@ static void print_metric_headers(struct perf_stat_config *config, struct evlist *evlist, const char *prefix, bool no_indent) { - struct perf_stat_output_ctx out; struct evsel *counter; struct outstate os = { .fh = config->output }; + struct perf_stat_output_ctx out = { + .ctx = &os, + .print_metric = print_metric_header, + .new_line = new_line_metric, + .force_header = true, + }; bool first = true; if (config->json_output && !config->interval) @@ -863,13 +868,11 @@ static void print_metric_headers(struct perf_stat_config *config, /* Print metrics headers only */ evlist__for_each_entry(evlist, counter) { os.evsel = counter; - out.ctx = &os; - out.print_metric = print_metric_header; + if (!first && config->json_output) fprintf(config->output, ", "); first = false; - out.new_line = new_line_metric; - out.force_header = true; + perf_stat__print_shadow_stats(config, counter, 0, 0, &out, |