From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751455AbdBFHXh (ORCPT ); Mon, 6 Feb 2017 02:23:37 -0500 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:35308 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750932AbdBFHXe (ORCPT ); Mon, 6 Feb 2017 02:23:34 -0500 X-Original-SENDERIP: 156.147.1.127 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , Minchan Kim , Taeung Song Subject: [PATCH 3/3] perf diff: Add diff.compute config option Date: Mon, 6 Feb 2017 16:20:37 +0900 Message-Id: <20170206072037.8189-4-namhyung@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170206072037.8189-1-namhyung@kernel.org> References: <20170206072037.8189-1-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The diff.compute config variable is to set the default compute method of perf diff command (-c option). Possible values 'delta' (default), 'delta-abs', 'ratio' and 'wdiff'. Cc: Taeung Song Signed-off-by: Namhyung Kim --- tools/perf/Documentation/perf-config.txt | 5 +++++ tools/perf/Documentation/perf-diff.txt | 5 +++-- tools/perf/builtin-diff.c | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt index 5b54d47ef713..f2d758dc1edc 100644 --- a/tools/perf/Documentation/perf-config.txt +++ b/tools/perf/Documentation/perf-config.txt @@ -505,6 +505,11 @@ Variables Setting it to 1 will sort the result by delta (or other compute method selected). + diff.compute:: + This options sets the method of computing diff result. + Possible values are 'delta', 'delta-abs', 'ratio' and + 'wdiff'. Default is 'delta'. + SEE ALSO -------- linkperf:perf[1] diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt index 6ba3bf582d79..70f490408262 100644 --- a/tools/perf/Documentation/perf-diff.txt +++ b/tools/perf/Documentation/perf-diff.txt @@ -86,8 +86,9 @@ OPTIONS -c:: --compute:: - Differential computation selection - delta,ratio,wdiff,delta-abs (default is delta). - See COMPARISON METHODS section for more info. + Differential computation selection - delta,ratio,wdiff,delta-abs + (default is delta). Default can be changed using diff.compute + config option. See COMPARISON METHODS section for more info. -p:: --period:: diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 181ff996e039..4b4004d41c6a 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -86,7 +86,7 @@ const char *compute_names[COMPUTE_MAX] = { [COMPUTE_WEIGHTED_DIFF] = "wdiff", }; -static int compute; +static int compute = COMPUTE_DELTA; static int compute_2_hpp[COMPUTE_MAX] = { [COMPUTE_DELTA] = PERF_HPP_DIFF__DELTA, @@ -1299,6 +1299,20 @@ static int diff__config(const char *var, const char *value, sort_compute = perf_config_int(var, value); return 0; } + if (!strcmp(var, "diff.compute")) { + if (!strcmp(value, "delta")) + compute = COMPUTE_DELTA; + else if (!strcmp(value, "delta-abs")) + compute = COMPUTE_DELTA_ABS; + else if (!strcmp(value, "ratio")) + compute = COMPUTE_RATIO; + else if (!strcmp(value, "wdiff")) + compute = COMPUTE_WEIGHTED_DIFF; + else { + pr_err("Invalid compute method: %s\n", value); + return -1; + } + } return 0; } -- 2.11.0