Skip to content

Commit

Permalink
perf diff: Add diff.order config option
Browse files Browse the repository at this point in the history
In many cases, I need to look at differences between two data so I often
used the -o option to sort the result base on the difference first.
It'd be nice to have a config option to set it by default.

The diff.order config option is to set the default value of -o/--order
option.

Signed-off-by: Namhyung Kim <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Taeung Song <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
namhyung authored and acmel committed Feb 13, 2017
1 parent a1668c2 commit d49dd15
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tools/perf/Documentation/perf-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,13 @@ record.*::
But if this option is 'no-cache', it will not update the build-id cache.
'skip' skips post-processing and does not update the cache.

diff.*::
diff.order::
This option sets the number of columns to sort the result.
The default is 0, which means sorting by baseline.
Setting it to 1 will sort the result by delta (or other
compute method selected).

SEE ALSO
--------
linkperf:perf[1]
6 changes: 5 additions & 1 deletion tools/perf/Documentation/perf-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ OPTIONS

-o::
--order::
Specify compute sorting column number.
Specify compute sorting column number. 0 means sorting by baseline
overhead (default) and 1 means sorting by computed value of column 1
(data from the first file other base baseline). Values more than 1
can be used only if enough data files are provided.
The default value can be set using the diff.order config option.

--percentage::
Determine how to display the overhead percentage of filtered entries.
Expand Down
14 changes: 14 additions & 0 deletions tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "util/symbol.h"
#include "util/util.h"
#include "util/data.h"
#include "util/config.h"

#include <stdlib.h>
#include <math.h>
Expand Down Expand Up @@ -1291,13 +1292,26 @@ static int data_init(int argc, const char **argv)
return 0;
}

static int diff__config(const char *var, const char *value,
void *cb __maybe_unused)
{
if (!strcmp(var, "diff.order")) {
sort_compute = perf_config_int(var, value);
return 0;
}

return 0;
}

int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
{
int ret = hists__init();

if (ret < 0)
return ret;

perf_config(diff__config, NULL);

argc = parse_options(argc, argv, options, diff_usage, 0);

if (symbol__init(NULL) < 0)
Expand Down

0 comments on commit d49dd15

Please sign in to comment.