Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp471853pxx; Wed, 28 Oct 2020 09:05:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU7Bvt24Uy7hnviuEYCjENAQyhmprOV8QV9ukUK+eFs0NoY7JTcpI3Je0OUu8ByHbqiUAB X-Received: by 2002:aa7:c14a:: with SMTP id r10mr8721598edp.345.1603901156728; Wed, 28 Oct 2020 09:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603901156; cv=none; d=google.com; s=arc-20160816; b=zTuJrAZ+/7IJOUHSRsrybIi3UowWKj1ff8J8xTf+RQ0o/DGam1ZuOL2djM6R1jodkz fGJPEFBP+n+JtJyvq4TwavCMEesYKpx08V6E4CfFV3jjLF7jWspiTedhcJmYT6CTCZVM Y4sDin3Do1/r9LcCg/UBgrzlbtQYlNkqWol5Ab56FR1jxrLICmqyPc08lTDG2Hcnmyu4 oU3MP+IoQWKa3Q33+wMbPLBnfr20iuvKPDLoK1IVf7emnoEbmd4kfu930g3e11DRQENe F6/LAVcqsMjOvRrhoKuB/ScWiZgpGUNeeWacM8b5NzS8zEnbVa6JNYA9u7Zi1pEz7Umk KBVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4GQtAIvQ48K3hSeqTVG5MnlYRRknD5uKH2dKCR+FyFo=; b=Rj5iVELl5yEHZYmstKb++yP8uT6OPIUo8G62aGeRZQ8ehF8O5/8rIEU3b5SeYJ76I8 zfQtZ5tasFHdnucSBI//Bw/NOo2ryO+A1StTIzSy6LuJDvOg7p+k6jJVJ3SyJqw23ITM 4YQrsELZJRooutTCrGEzOxEwhgiaGA/6U8evVU9nSMZkb1/KC2HxDNnoLA6CAU1SvajU eVkoQuQXHIpjmdKhnJ/D8nCDdpGCHqmKz17qdPNy2XOVg6VlNRvwo6VzZZwOLXL/EO0A carEKF/8VBs0RDquNAkL4aHkUL3RNIDmssdF7i4H2TAHqrEhfzfP9dD4GcyBGXx6ALyy doAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ier26cMI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si3402013edu.343.2020.10.28.09.05.34; Wed, 28 Oct 2020 09:05:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ier26cMI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1814714AbgJ0Q7g (ORCPT + 99 others); Tue, 27 Oct 2020 12:59:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:44938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1793958AbgJ0PJ3 (ORCPT ); Tue, 27 Oct 2020 11:09:29 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E94A221527; Tue, 27 Oct 2020 15:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811368; bh=dfnQ29Bwjxa8Ak1ZqRHzctBvx8PsvFmxe3f9gSdFQCM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ier26cMIyP81tqsHUXp4UiuyXYF7UOu1h7cuEg/ecIDHzOKlyhXpc84ozgsuLGybB tOErB0BC/kJ/7El96XqxJoSQoKH4F6V1Tk/wzGKWnBKumUH3hpIyjLKwy+PcQjrABa BJq4ejASng14+/Kw2NoMPXLVYe0Jy06S2x3oobtM= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id E9A01403C2; Tue, 27 Oct 2020 12:09:25 -0300 (-03) Date: Tue, 27 Oct 2020 12:09:25 -0300 From: Arnaldo Carvalho de Melo To: Andi Kleen Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org, alexey.budankov@linux.intel.com Subject: Re: [PATCH 1/2] perf tools: Add --quiet option to perf stat Message-ID: <20201027150925.GE2479604@kernel.org> References: <20201027002737.30942-1-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201027002737.30942-1-andi@firstfloor.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Oct 26, 2020 at 05:27:36PM -0700, Andi Kleen escreveu: > Add a new --quiet option to perf stat. This is useful with perf stat > record to write the data only to the perf.data file, which can lower > measurement overhead because the data doesn't need to be formatted. > > On my 4C desktop: > > % time ./perf stat record -e $(python -c 'print ",".join(["cycles"]*1000)') -a -I 1000 sleep 5 > ... > real 0m5.377s > user 0m0.238s > sys 0m0.452s > % time ./perf stat record --quiet -e $(python -c 'print ",".join(["cycles"]*1000)') -a -I 1000 sleep 5 > > real 0m5.452s > user 0m0.183s > sys 0m0.423s > > In this example it cuts the user time by 20%. On systems with more cores > the savings are higher. Applied 1/2, Thanks, - Arnaldo > Signed-off-by: Andi Kleen > --- > tools/perf/Documentation/perf-stat.txt | 4 ++++ > tools/perf/builtin-stat.c | 6 +++++- > tools/perf/util/stat.h | 1 + > 3 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt > index 9f9f29025e49..b138dd192423 100644 > --- a/tools/perf/Documentation/perf-stat.txt > +++ b/tools/perf/Documentation/perf-stat.txt > @@ -316,6 +316,10 @@ small group that need not have multiplexing is lowered. This option > forbids the event merging logic from sharing events between groups and > may be used to increase accuracy in this case. > > +--quiet:: > +Don't print output. This is useful with perf stat record below to only > +write data to the perf.data file. > + > STAT RECORD > ----------- > Stores stat data into perf data file. > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c > index b01af171d94f..743fe47e7a88 100644 > --- a/tools/perf/builtin-stat.c > +++ b/tools/perf/builtin-stat.c > @@ -972,6 +972,8 @@ static void print_counters(struct timespec *ts, int argc, const char **argv) > /* Do not print anything if we record to the pipe. */ > if (STAT_RECORD && perf_stat.data.is_pipe) > return; > + if (stat_config.quiet) > + return; > > perf_evlist__print_counters(evsel_list, &stat_config, &target, > ts, argc, argv); > @@ -1171,6 +1173,8 @@ static struct option stat_options[] = { > "threads of same physical core"), > OPT_BOOLEAN(0, "summary", &stat_config.summary, > "print summary for interval mode"), > + OPT_BOOLEAN(0, "quiet", &stat_config.quiet, > + "don't print output (useful with record)"), > #ifdef HAVE_LIBPFM > OPT_CALLBACK(0, "pfm-events", &evsel_list, "event", > "libpfm4 event selector. use 'perf list' to list available events", > @@ -2132,7 +2136,7 @@ int cmd_stat(int argc, const char **argv) > goto out; > } > > - if (!output) { > + if (!output && !stat_config.quiet) { > struct timespec tm; > mode = append_file ? "a" : "w"; > > diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h > index 487010c624be..05adf8165025 100644 > --- a/tools/perf/util/stat.h > +++ b/tools/perf/util/stat.h > @@ -122,6 +122,7 @@ struct perf_stat_config { > bool metric_no_group; > bool metric_no_merge; > bool stop_read_counter; > + bool quiet; > FILE *output; > unsigned int interval; > unsigned int timeout; > -- > 2.28.0 > -- - Arnaldo