diff options
author | Ian Rogers <irogers@google.com> | 2023-04-07 22:44:55 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-10 19:15:48 -0300 |
commit | 4228df84f952ff12540510a5c6cd00e976d992ab (patch) | |
tree | 71eb4b75cb50410d20d5e24edccbe2b2f88d18d4 /tools | |
parent | 220368293a010d39fe41f130b99b666394034b08 (diff) |
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 <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Link: https://lore.kernel.org/r/20230408054456.3001367-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-stat.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 38133afda7fc..40770926a230 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); |