linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: ufo19890607 <ufo19890607@gmail.com>
Cc: peterz@infradead.org, mingo@redhat.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	dsahern@gmail.com, namhyung@kernel.org, milian.wolff@kdab.com,
	arnaldo.melo@gmail.com, yuzhoujian@didichuxing.com,
	adrian.hunter@intel.com, wangnan0@huawei.com,
	Kan.liang@intel.com, linux-perf-users@vger.kernel.org,
	linux-kernel@vger.kernel.org, acme@redhat.com
Subject: Re: [PATCH v3 1/2] perf stat: Add support to print counts for fixed times
Date: Mon, 29 Jan 2018 08:29:49 +0100	[thread overview]
Message-ID: <20180129072949.GB8162@krava> (raw)
In-Reply-To: <1516957617-23985-2-git-send-email-ufo19890607@gmail.com>

On Fri, Jan 26, 2018 at 10:06:56AM +0100, ufo19890607 wrote:

SNIP

> @@ -1891,6 +1902,8 @@ static const struct option stat_options[] = {
>  			"command to run after to the measured command"),
>  	OPT_UINTEGER('I', "interval-print", &stat_config.interval,
>  		    "print counts at regular interval in ms (>= 10)"),
> +	OPT_INTEGER(0, "interval-count", &stat_config.times,
> +		    "print counts for fixed number of times"),
>  	OPT_SET_UINT(0, "per-socket", &stat_config.aggr_mode,
>  		     "aggregate counts per processor socket", AGGR_SOCKET),
>  	OPT_SET_UINT(0, "per-core", &stat_config.aggr_mode,
> @@ -2689,6 +2702,7 @@ int cmd_stat(int argc, const char **argv)
>  	const char *mode;
>  	FILE *output = stderr;
>  	unsigned int interval;
> +	int times;
>  	const char * const stat_subcommands[] = { "record", "report" };
>  
>  	setlocale(LC_ALL, "");
> @@ -2719,6 +2733,7 @@ int cmd_stat(int argc, const char **argv)
>  		return __cmd_report(argc, argv);
>  
>  	interval = stat_config.interval;
> +	times = stat_config.times;
>  
>  	/*
>  	 * For record command the -o is already taken care of.
> @@ -2870,6 +2885,15 @@ int cmd_stat(int argc, const char **argv)
>  				   "The overhead percentage could be high in some cases. "
>  				   "Please proceed with caution.\n");
>  	}
> +	if (times && interval)
> +		interval_count = true;
> +	else if (times && !interval) {

you can use stat_config.times in here, no need for 'times' copy

jirka

> +		pr_err("interval-count option should be used together with "
> +				"interval-print.\n");
> +		parse_options_usage(stat_usage, stat_options, "interval-count", 0);
> +		parse_options_usage(stat_usage, stat_options, "I", 1);
> +		goto out;
> +	}
>  
>  	if (perf_evlist__alloc_stats(evsel_list, interval))
>  		goto out;
> diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
> index dbc6f7134f61..b2f8a347d358 100644
> --- a/tools/perf/util/stat.h
> +++ b/tools/perf/util/stat.h
> @@ -90,6 +90,7 @@ struct perf_stat_config {
>  	bool		scale;
>  	FILE		*output;
>  	unsigned int	interval;
> +	int				times;
>  	struct runtime_stat *stats;
>  	int		stats_num;
>  };
> -- 
> 2.14.1
> 

  parent reply	other threads:[~2018-01-29  7:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26  9:06 [PATCH v3 0/2] perf stat: Add interval-count and time support ufo19890607
2018-01-26  9:06 ` [PATCH v3 1/2] perf stat: Add support to print counts for fixed times ufo19890607
2018-01-29  7:29   ` Jiri Olsa
2018-01-29  7:29   ` Jiri Olsa [this message]
2018-01-26  9:06 ` [PATCH v3 2/2] perf stat: Add support to print counts after a period of time ufo19890607

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=20180129072949.GB8162@krava \
    --to=jolsa@redhat.com \
    --cc=Kan.liang@intel.com \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=milian.wolff@kdab.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ufo19890607@gmail.com \
    --cc=wangnan0@huawei.com \
    --cc=yuzhoujian@didichuxing.com \
    /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;
as well as URLs for NNTP newsgroup(s).