mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: acme@kernel.org
Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>
Subject: [PATCH] perf, tools, stat: Print warning when no metric with --metric-only
Date: Thu, 10 Mar 2016 06:27:17 -0800	[thread overview]
Message-ID: <1457620037-2978-1-git-send-email-andi@firstfloor.org> (raw)

From: Andi Kleen <ak@linux.intel.com>

Print a warning when --metric-only is specified, but the events
define no metric. Requested by Jiri.

% perf stat -e cycles --metric-only true

 Performance counter stats for 'true':

No metrics defined by configured events

       0.001612070 seconds time elapsed

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/builtin-stat.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1f19f2f..70efb58 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -743,6 +743,7 @@ struct outstate {
 	int  nfields;
 	int  id, nr;
 	struct perf_evsel *evsel;
+	int nheaders;
 };
 
 #define METRIC_LEN  35
@@ -919,6 +920,7 @@ static void print_metric_header(void *ctx, const char *color __maybe_unused,
 		fprintf(os->fh, "%s%s", unit, csv_sep);
 	else
 		fprintf(os->fh, "%-*s ", METRIC_ONLY_LEN, unit);
+	os->nheaders++;
 }
 
 static void nsec_printout(int id, int nr, struct perf_evsel *evsel, double avg)
@@ -1315,6 +1317,8 @@ static void print_metric_headers(char *prefix)
 					      &out);
 	}
 	fputc('\n', stat_config.output);
+	if (os.nheaders == 0)
+		pr_warning("No metrics defined by configured events\n");
 }
 
 static void print_interval(char *prefix, struct timespec *ts)
-- 
2.5.0

             reply	other threads:[~2016-03-10 14:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-10 14:27 Andi Kleen [this message]
2016-03-11  8:06 ` Jiri Olsa
2016-03-11 23:04   ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457620037-2978-1-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®