Received: by 10.223.176.5 with SMTP id f5csp2546432wra; Sun, 28 Jan 2018 23:29:56 -0800 (PST) X-Google-Smtp-Source: AH8x226PeK0vlAu+kEuP6BHFAZFtxT72zYMCzlsjiOR+dlS0o4fEa962kg5W5nhHkpJAwn+z4O/I X-Received: by 10.98.9.67 with SMTP id e64mr25682642pfd.230.1517210996402; Sun, 28 Jan 2018 23:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517210996; cv=none; d=google.com; s=arc-20160816; b=O13bgEFaVSgukRgni4hiFBqOiymrKCu6P4Au8XMGA2k5PLGUtVRctUKBsZOZdMHiFv KEW2onbQZqMIFDe/HP7nY6H5TULUZSNgofkyK+oL53t8nOkU6N72Mfj7MoW5EA9joUfR XIj0x/N8n4BPUXhgvy7xIikQ7f48E7UprOQqgGyvHfC5IEcf9/XtKPwH7FoKCRyrijq7 p0C0Qa77X09YBe/fIco7wHUlKd52nbUC2zM9T6woC+4YMVjLtY1BuBW9MXL013aRq0Ww zhfy4gTLx4CPgZKyilRal1sHzbKLINVJaWq1VnUN0MJLXAkYiUImz4v58B7ncvERF5f/ IoEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=czGDnGNj16Uo3uQHL7mlvCmNlDhyR7IMdeLLErGx3gY=; b=ARHForHIwcK1dt8mSAII/rp1OY57AxO/OWoDArbWfVJfT440YbT1qeM0NNsssn3B78 +GTIaZnx1/TSamtgsK3rz9oZZeiKXyO+ZMAbCsflRcfe9Ia2DH31ky84KRZUM2NOEfQb 61ktxohBpgqFuLO0P88y29mhA5QoZPAA3dsd/9ixCTUGW5ITFQ/vQjkiYiNqq9cqjUuY VXin5MbDbZAIgCg9mh3e6iK4wC9Hb8MdlbZAi7qF2h4IM56Mgj1FQAoX5mFRgO8rBuw5 fOyVDPJC2ZH1+oa+x3jG8x3onHodbz/hbX6AiMd8CLeCF/H5p2ZMXQZUiIY1XCse7YPM alkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s72si799008pgc.149.2018.01.28.23.29.42; Sun, 28 Jan 2018 23:29:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbeA2H3P (ORCPT + 99 others); Mon, 29 Jan 2018 02:29:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33732 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbeA2H3N (ORCPT ); Mon, 29 Jan 2018 02:29:13 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 171F685545; Mon, 29 Jan 2018 07:29:13 +0000 (UTC) Received: from krava (unknown [10.43.17.162]) by smtp.corp.redhat.com (Postfix) with SMTP id 6EBCA60C95; Mon, 29 Jan 2018 07:29:06 +0000 (UTC) Date: Mon, 29 Jan 2018 08:29:05 +0100 From: Jiri Olsa To: ufo19890607 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 Message-ID: <20180129072905.GA8162@krava> References: <1516957617-23985-1-git-send-email-ufo19890607@gmail.com> <1516957617-23985-2-git-send-email-ufo19890607@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516957617-23985-2-git-send-email-ufo19890607@gmail.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 29 Jan 2018 07:29:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 26, 2018 at 10:06:56AM +0100, ufo19890607 wrote: SNIP > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -168,6 +168,7 @@ static struct timespec ref_time; > static struct cpu_map *aggr_map; > static aggr_get_id_t aggr_get_id; > static bool append_file; > +static bool interval_count; > static const char *output_name; > static int output_fd; > static int print_free_counters_hint; > @@ -571,6 +572,7 @@ static struct perf_evsel *perf_evsel__reset_weak_group(struct perf_evsel *evsel) > static int __run_perf_stat(int argc, const char **argv) > { > int interval = stat_config.interval; > + int times = stat_config.times; > char msg[BUFSIZ]; > unsigned long long t0, t1; > struct perf_evsel *counter; > @@ -700,6 +702,10 @@ static int __run_perf_stat(int argc, const char **argv) > while (!waitpid(child_pid, &status, WNOHANG)) { > nanosleep(&ts, NULL); > process_interval(); > + if (interval_count == true) { > + if (--times == 0) > + break; why not single line in here? if (interval_count && !(--times)) > + } > } > } > waitpid(child_pid, &status, 0); > @@ -716,8 +722,13 @@ static int __run_perf_stat(int argc, const char **argv) > enable_counters(); > while (!done) { > nanosleep(&ts, NULL); > - if (interval) > + if (interval) { > process_interval(); > + if (interval_count == true) { > + if (--times == 0) > + break; same here SNIP > } > + if (times && interval) > + interval_count = true; > + else if (times && !interval) { > + 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; wrong indent thanks, jirka > struct runtime_stat *stats; > int stats_num; > }; > -- > 2.14.1 >