Adding option 'o' to allow sorting based on the input file number. Signed-off-by: Jiri Olsa <jo...@redhat.com> Cc: Arnaldo Carvalho de Melo <a...@ghostprotocols.net> Cc: Peter Zijlstra <a.p.zijls...@chello.nl> Cc: Ingo Molnar <mi...@elte.hu> Cc: Paul Mackerras <pau...@samba.org> Cc: Corey Ashford <cjash...@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweis...@gmail.com> Cc: Namhyung Kim <namhy...@kernel.org> --- tools/perf/Documentation/perf-diff.txt | 4 +++ tools/perf/builtin-diff.c | 53 +++++++++++++++------------------- 2 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt index ab5b79e..1402e14 100644 --- a/tools/perf/Documentation/perf-diff.txt +++ b/tools/perf/Documentation/perf-diff.txt @@ -91,6 +91,10 @@ OPTIONS --formula:: Show formula for given computation. +-o:: +--order:: + Specify compute sorting column number. + COMPARISON ---------- The comparison is governed by the baseline file. The baseline perf.data diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index b801d0c..1f98786 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -65,7 +65,7 @@ static bool show_displacement; static bool show_period; static bool show_formula; static bool show_baseline_only; -static bool sort_compute; +static unsigned int sort_compute; static s64 compute_wdiff_w1; static s64 compute_wdiff_w2; @@ -191,13 +191,6 @@ static int setup_compute(const struct option *opt, const char *str, return 0; } - if (*str == '+') { - sort_compute = true; - cstr = (char *) ++str; - if (!*str) - return 0; - } - option = strchr(str, ':'); if (option) { unsigned len = option++ - str; @@ -533,31 +526,27 @@ static int64_t hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right, int c) { - int i; + struct hist_entry **pairs_left = left->pairs; + struct hist_entry **pairs_right = right->pairs; + struct hist_entry *p_right, *p_left; + static int64_t cmp; - for (i = 0; i < data_cnt; i++) { - struct hist_entry **pairs_left = left->pairs; - struct hist_entry **pairs_right = right->pairs; - struct hist_entry *p_right, *p_left; - static int64_t cmp; + if (!pairs_left || !pairs_right) + return pairs_left ? -1 : 1; - if (!pairs_left || !pairs_right) - return pairs_right - pairs_left; + p_right = pairs_right[sort_compute]; + p_left = pairs_left[sort_compute]; - p_right = pairs_right[i]; - p_left = pairs_left[i]; + if (!p_left || !p_right) + return p_left ? -1 : 1; - if (!p_left || !p_right) - return p_right - p_left; - - /* - * If we differ, we are done, otherwise continue until all - * is processed or we find a difference. - */ - cmp = __hist_entry__cmp_compute(p_left, p_right, c); - if (cmp) - return cmp; - } + /* + * If we differ, we are done, otherwise continue until all + * is processed or we find a difference. + */ + cmp = __hist_entry__cmp_compute(p_left, p_right, c); + if (cmp) + return cmp; return 0; } @@ -759,6 +748,7 @@ static const struct option options[] = { "columns '.' is reserved."), OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", "Look for files with symbols relative to this directory"), + OPT_UINTEGER('o', "order", &sort_compute, "Specify compute sorting."), OPT_END() }; @@ -1087,6 +1077,11 @@ static int data_init(int argc, const char **argv) d->idx = i; } + if (sort_compute >= (unsigned int) data_cnt) { + pr_err("Order option out of limit.\n"); + return -EINVAL; + } + return 0; } -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/