Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf diff: Add diff.compute config option

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'.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Taeung Song <treeze.taeung@gmail.com>
Link: http://lkml.kernel.org/r/20170210073614.24584-4-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
4b35994a d49dd15d

+23 -3
+5
tools/perf/Documentation/perf-config.txt
··· 505 505 Setting it to 1 will sort the result by delta (or other 506 506 compute method selected). 507 507 508 + diff.compute:: 509 + This options sets the method for computing the diff result. 510 + Possible values are 'delta', 'delta-abs', 'ratio' and 511 + 'wdiff'. Default is 'delta'. 512 + 508 513 SEE ALSO 509 514 -------- 510 515 linkperf:perf[1]
+3 -2
tools/perf/Documentation/perf-diff.txt
··· 86 86 87 87 -c:: 88 88 --compute:: 89 - Differential computation selection - delta,ratio,wdiff,delta-abs (default is delta). 90 - See COMPARISON METHODS section for more info. 89 + Differential computation selection - delta, ratio, wdiff, delta-abs 90 + (default is delta). Default can be changed using diff.compute 91 + config option. See COMPARISON METHODS section for more info. 91 92 92 93 -p:: 93 94 --period::
+15 -1
tools/perf/builtin-diff.c
··· 86 86 [COMPUTE_WEIGHTED_DIFF] = "wdiff", 87 87 }; 88 88 89 - static int compute; 89 + static int compute = COMPUTE_DELTA; 90 90 91 91 static int compute_2_hpp[COMPUTE_MAX] = { 92 92 [COMPUTE_DELTA] = PERF_HPP_DIFF__DELTA, ··· 1298 1298 if (!strcmp(var, "diff.order")) { 1299 1299 sort_compute = perf_config_int(var, value); 1300 1300 return 0; 1301 + } 1302 + if (!strcmp(var, "diff.compute")) { 1303 + if (!strcmp(value, "delta")) { 1304 + compute = COMPUTE_DELTA; 1305 + } else if (!strcmp(value, "delta-abs")) { 1306 + compute = COMPUTE_DELTA_ABS; 1307 + } else if (!strcmp(value, "ratio")) { 1308 + compute = COMPUTE_RATIO; 1309 + } else if (!strcmp(value, "wdiff")) { 1310 + compute = COMPUTE_WEIGHTED_DIFF; 1311 + } else { 1312 + pr_err("Invalid compute method: %s\n", value); 1313 + return -1; 1314 + } 1301 1315 } 1302 1316 1303 1317 return 0;