[PATCH 21/23] perf stat: Add -q/--quiet option

From: Namhyung Kim
Date: Tue Mar 07 2017 - 10:21:07 EST


The -q/--quiet option is to suppress any message. Sometimes users just
want to run the command and it can be used for that case.

Suggested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/Documentation/perf-stat.txt | 4 ++++
tools/perf/builtin-stat.c | 7 +++++++
2 files changed, 11 insertions(+)

diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index aecf2a87e7d6..94482b8a597b 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -105,6 +105,10 @@ This option is only valid in system-wide mode.
--verbose::
be more verbose (show counter open errors, etc)

+-q::
+--quiet::
+ Do not show any message. (Suppress -v)
+
-x SEP::
--field-separator SEP::
print counts using a CSV-style output to make it easy to import directly into
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index ee7190da9b6e..9dbb08c038e1 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1630,6 +1630,7 @@ static const struct option stat_options[] = {
OPT_BOOLEAN('c', "scale", &stat_config.scale, "scale/normalize counters"),
OPT_INCR('v', "verbose", &verbose,
"be more verbose (show counter open errors, etc)"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_INTEGER('r', "repeat", &run_count,
"repeat command and print average + stddev (max: 100, forever: 0)"),
OPT_BOOLEAN('n', "null", &null_run,
@@ -2163,6 +2164,9 @@ static int __cmd_record(int argc, const char **argv)
argc = parse_options(argc, argv, stat_options, stat_record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);

+ if (quiet)
+ perf_quiet_option();
+
if (output_name)
file->path = output_name;

@@ -2410,6 +2414,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
PARSE_OPT_STOP_AT_NON_OPTION);
perf_stat__init_shadow_stats();

+ if (quiet)
+ perf_quiet_option();
+
if (csv_sep) {
csv_output = true;
if (!strcmp(csv_sep, "\\t"))
--
2.11.0