From: Ian Rogers Date: Sat, 8 Apr 2023 05:44:55 +0000 (-0700) Subject: perf stat: Don't write invalid "started on" comment for JSON output X-Git-Tag: v6.4-rc1~1^2~121 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4228df84f952ff12540510a5c6cd00e976d992ab;p=thirdparty%2Flinux.git perf stat: Don't write invalid "started on" comment for JSON output JSON files don't support comments. Disable the "started on" comment when writing json output to file. Signed-off-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Athira Rajeev Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Sumanth Korikkar Cc: Thomas Richter Link: https://lore.kernel.org/r/20230408054456.3001367-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 38133afda7fce..40770926a2309 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2272,8 +2272,10 @@ int cmd_stat(int argc, const char **argv) perror("failed to create output file"); return -1; } - clock_gettime(CLOCK_REALTIME, &tm); - fprintf(output, "# started on %s\n", ctime(&tm.tv_sec)); + if (!stat_config.json_output) { + clock_gettime(CLOCK_REALTIME, &tm); + fprintf(output, "# started on %s\n", ctime(&tm.tv_sec)); + } } else if (output_fd > 0) { mode = append_file ? "a" : "w"; output = fdopen(output_fd, mode);