Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1382782imm; Wed, 6 Jun 2018 15:18:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLtuCt3UDdYNrsxJk7mqwmfoLm2yvHF8ABceQKp37lBp07A8kgXvDOF1w8DorOMlnTSLLzY X-Received: by 2002:a65:6355:: with SMTP id p21-v6mr3939899pgv.293.1528323499194; Wed, 06 Jun 2018 15:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528323498; cv=none; d=google.com; s=arc-20160816; b=xJ8yzym30Gs1YCGy44PoWOWg8JswTAA8AEg4tE+k8H1KuAL2FTm1SHJ5d9Z9ymuexe OBdMJFG7pBXXtR3tjfFzol6Sa36W4jKO3Od1U6bt7i+Vbl/gMEUkvby0+EA5Q4zltVXW 7Yja1D3xlO6rxDfx7PZ5t61FyMgBUyhRZamkk7JJTe4tMBm+/hKokiF53wvdscEbZHlM gPy6Bm+apbrY10oSc2Ej88JyroukkZAKYhJVoVv2OsXibi9mq/SUxOkx7Ld2fzlIiwV3 4uNB2/2jMIy5vpElj1YnhpmMReLoXWQCeDhtpDp0XxXW+j92yp3tDOhP/rq6ZBawN0X2 4B4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=XOz1m/NywqhdWYa/oCyPNf+Ufkv6iSftoMK9CUfuUkc=; b=Mic8MZMixk6vMQuJlszjR9G90A2NaYNffCBDa/KlumucXaE0HTBmsl4z8revz4cVbT vd2806+ctP3eTlc978ZvZJQJthCX20HptlUeZzyqHsl5GRjz/qXLVrGz5tRqPHrX6lGa KjO3Wkmz8FmdS/m+sg2L+znGGwPi9vSAoV7FClfsKiU5G1RAUfKXD3ed6oyqHGX8Yk2G ElYmTHIAUxa0JelIPKZKVjZ0/zqfxtibKS0mfiLeKeB4s4W3AOsSAj62voibLP1dH+er hXzBztphmz44CLW+JVHnn8GdqWd0SIFc+68BWZuQQCE6vGJt0ePqD30s5dm02HZnh7mK F7Jw== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj1-v6si51016160plb.395.2018.06.06.15.18.04; Wed, 06 Jun 2018 15:18:18 -0700 (PDT) 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753002AbeFFWRM (ORCPT + 99 others); Wed, 6 Jun 2018 18:17:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46260 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752404AbeFFWP2 (ORCPT ); Wed, 6 Jun 2018 18:15:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCE8D8A3CE; Wed, 6 Jun 2018 22:15:27 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-89.brq.redhat.com [10.40.204.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 723172026DEF; Wed, 6 Jun 2018 22:15:25 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo , Peter Zijlstra Cc: lkml , Ingo Molnar , Namhyung Kim , David Ahern , Alexander Shishkin , Stephane Eranian , Milian Wolff , Andi Kleen , Frederic Weisbecker Subject: [PATCH 03/10] perf stat: Add --interval-clear option Date: Thu, 7 Jun 2018 00:15:06 +0200 Message-Id: <20180606221513.11302-4-jolsa@kernel.org> In-Reply-To: <20180606221513.11302-1-jolsa@kernel.org> References: <20180606221513.11302-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 06 Jun 2018 22:15:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 06 Jun 2018 22:15:27 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@kernel.org' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding --interval-clear option to clear the screen before next interval. Link: http://lkml.kernel.org/n/tip-8zobiwghr6t9f9a4o886cmau@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/Documentation/perf-stat.txt | 3 +++ tools/perf/builtin-stat.c | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt index 5dfe102fb5b5..b10a90b6a718 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -178,6 +178,9 @@ Print count deltas for fixed number of times. This option should be used together with "-I" option. example: 'perf stat -I 1000 --interval-count 2 -e cycles -a' +--interval-clear:: +Clear the screen before next interval. + --timeout msecs:: Stop the 'perf stat' session and print count deltas after N milliseconds (minimum: 10 ms). This option is not supported with the "-I" option. diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index fce46252f89c..067d8b5b2c83 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -65,6 +65,7 @@ #include "util/tool.h" #include "util/string2.h" #include "util/metricgroup.h" +#include "util/top.h" #include "asm/bug.h" #include @@ -173,6 +174,7 @@ static struct cpu_map *aggr_map; static aggr_get_id_t aggr_get_id; static bool append_file; static bool interval_count; +static bool interval_clear; static const char *output_name; static int output_fd; static int print_free_counters_hint; @@ -1713,9 +1715,12 @@ static void print_interval(char *prefix, struct timespec *ts) FILE *output = stat_config.output; static int num_print_interval; + if (interval_clear) + puts(CONSOLE_CLEAR); + sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep); - if (num_print_interval == 0 && !csv_output) { + if ((num_print_interval == 0 && !csv_output) || interval_clear) { switch (stat_config.aggr_mode) { case AGGR_SOCKET: fprintf(output, "# time socket cpus"); @@ -1747,7 +1752,7 @@ static void print_interval(char *prefix, struct timespec *ts) } } - if (num_print_interval == 0 && metric_only) + if ((num_print_interval == 0 && metric_only) || interval_clear) print_metric_headers(" ", true); if (++num_print_interval == 25) num_print_interval = 0; @@ -2066,6 +2071,8 @@ static const struct option stat_options[] = { "(overhead is possible for values <= 100ms)"), OPT_INTEGER(0, "interval-count", &stat_config.times, "print counts for fixed number of times"), + OPT_BOOLEAN(0, "interval-clear", &interval_clear, + "clear screen in between new interval"), OPT_UINTEGER(0, "timeout", &stat_config.timeout, "stop workload and print counts after a timeout period in ms (>= 10ms)"), OPT_SET_UINT(0, "per-socket", &stat_config.aggr_mode, -- 2.13.6