perf stat: Clear screen only if output file is a tty
authorNamhyung Kim <namhyung@kernel.org>
Mon, 14 Nov 2022 23:02:09 +0000 (15:02 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 16 Nov 2022 12:51:22 +0000 (09:51 -0300)
commitf5bc4428cc6e096170d35fc79a640d90e33dd9c3
tree6cb14d93c4c449d119ddd9c43b80217a957c2a94
parenteb2d4514a5971444f67ac8b95bcd63e7702fa6bf
perf stat: Clear screen only if output file is a tty

The --interval-clear option makes perf stat to clear the terminal at
each interval.  But it doesn't need to clear the screen when it saves
to a file.  Make it fail when it's enabled with the output options.

  $ perf stat -I 1 --interval-clear -o myfile true
  --interval-clear does not work with output

   Usage: perf stat [<options>] [<command>]

      -o, --output <file>   output file name
          --log-fd <n>      log output to fd, instead of stderr
          --interval-clear  clear screen in between new interval

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.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/20221114230227.1255976-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-stat.c