Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1583190

[PATCH 4/6] perf diff: Add -q/--quiet option

From Namhyung Kim <namhyung@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 4/6] perf diff: Add -q/--quiet option
Date 2017-02-17 09:20 +0100
Message-ID <tbLVM-1GO-23@gated-at.bofh.it> (permalink)
References <tbLVL-1GO-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-diff.txt |  4 ++++
 tools/perf/builtin-diff.c              | 14 ++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt
index 66dbe3dee74b..a79c84ae61aa 100644
--- a/tools/perf/Documentation/perf-diff.txt
+++ b/tools/perf/Documentation/perf-diff.txt
@@ -73,6 +73,10 @@ OPTIONS
 	Be verbose, for instance, show the raw counts in addition to the
 	diff.
 
+-q::
+--quiet::
+	Do not show any message.  (Suppress -v)
+
 -f::
 --force::
         Don't do ownership validation.
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 70a289347591..1b96a3122228 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -691,7 +691,7 @@ static void hists__process(struct hists *hists)
 	hists__precompute(hists);
 	hists__output_resort(hists, NULL);
 
-	hists__fprintf(hists, true, 0, 0, 0, stdout,
+	hists__fprintf(hists, !quiet, 0, 0, 0, stdout,
 		       symbol_conf.use_callchain);
 }
 
@@ -739,12 +739,14 @@ static void data_process(void)
 				hists__link(hists_base, hists);
 		}
 
-		fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
-			perf_evsel__name(evsel_base));
+		if (!quiet) {
+			fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n",
+				perf_evsel__name(evsel_base));
+		}
 
 		first = false;
 
-		if (verbose || data__files_cnt > 2)
+		if (verbose > 0 || ((data__files_cnt > 2) && !quiet))
 			data__fprintf();
 
 		/* Don't sort callchain for perf diff */
@@ -807,6 +809,7 @@ static const char * const diff_usage[] = {
 static const struct option options[] = {
 	OPT_INCR('v', "verbose", &verbose,
 		    "be more verbose (show symbol address, etc)"),
+	OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
 	OPT_BOOLEAN('b', "baseline-only", &show_baseline_only,
 		    "Show only items with match in baseline"),
 	OPT_CALLBACK('c', "compute", &compute,
@@ -1328,6 +1331,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	argc = parse_options(argc, argv, options, diff_usage, 0);
 
+	if (quiet)
+		perf_quiet_option();
+
 	if (symbol__init(NULL) < 0)
 		return -1;
 
-- 
2.11.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHSET 0/6] perf tools: Add -q/--quiet option to suppress messages (v1) Namhyung Kim <namhyung@kernel.org> - 2017-02-17 09:20 +0100
  [PATCH 1/6] perf utils: Add perf_quiet_option() Namhyung Kim <namhyung@kernel.org> - 2017-02-17 09:20 +0100
    [tip:perf/urgent] perf utils: Add perf_quiet_option() tip-bot for Namhyung Kim <tipbot@zytor.com> - 2017-02-21 09:20 +0100
  [PATCH 4/6] perf diff: Add -q/--quiet option Namhyung Kim <namhyung@kernel.org> - 2017-02-17 09:20 +0100
    [tip:perf/urgent] perf diff: Add -q/--quiet option tip-bot for Namhyung Kim <tipbot@zytor.com> - 2017-02-21 09:20 +0100
  [PATCH 3/6] perf report: Add -q/--quiet option Namhyung Kim <namhyung@kernel.org> - 2017-02-17 09:20 +0100
    Re: [PATCH 3/6] perf report: Add -q/--quiet option Jiri Olsa <jolsa@redhat.com> - 2017-02-17 12:20 +0100
      Re: [PATCH 3/6] perf report: Add -q/--quiet option Namhyung Kim <namhyung@kernel.org> - 2017-02-19 01:40 +0100
    Re: [PATCH 3/6] perf report: Add -q/--quiet option Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-20 20:10 +0100
      Re: [PATCH 3/6] perf report: Add -q/--quiet option Namhyung Kim <namhyung@kernel.org> - 2017-02-21 02:50 +0100
    [tip:perf/urgent] perf report: Add -q/--quiet option tip-bot for Namhyung Kim <tipbot@zytor.com> - 2017-02-21 09:20 +0100
  [PATCH 6/6] perf record: Honor quiet option properly Namhyung Kim <namhyung@kernel.org> - 2017-02-17 09:20 +0100
    [tip:perf/urgent] perf record: Honor --quiet option properly tip-bot for Namhyung Kim <tipbot@zytor.com> - 2017-02-21 09:20 +0100

csiph-web