diff options
Diffstat (limited to 'tools/perf/builtin-diff.c')
| -rw-r--r-- | tools/perf/builtin-diff.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 933aeec46f4a..781c9e60bd21 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
| @@ -30,6 +30,7 @@ enum { | |||
| 30 | PERF_HPP_DIFF__RATIO, | 30 | PERF_HPP_DIFF__RATIO, |
| 31 | PERF_HPP_DIFF__WEIGHTED_DIFF, | 31 | PERF_HPP_DIFF__WEIGHTED_DIFF, |
| 32 | PERF_HPP_DIFF__FORMULA, | 32 | PERF_HPP_DIFF__FORMULA, |
| 33 | PERF_HPP_DIFF__DELTA_ABS, | ||
| 33 | 34 | ||
| 34 | PERF_HPP_DIFF__MAX_INDEX | 35 | PERF_HPP_DIFF__MAX_INDEX |
| 35 | }; | 36 | }; |
| @@ -73,11 +74,13 @@ enum { | |||
| 73 | COMPUTE_DELTA, | 74 | COMPUTE_DELTA, |
| 74 | COMPUTE_RATIO, | 75 | COMPUTE_RATIO, |
| 75 | COMPUTE_WEIGHTED_DIFF, | 76 | COMPUTE_WEIGHTED_DIFF, |
| 77 | COMPUTE_DELTA_ABS, | ||
| 76 | COMPUTE_MAX, | 78 | COMPUTE_MAX, |
| 77 | }; | 79 | }; |
| 78 | 80 | ||
| 79 | const char *compute_names[COMPUTE_MAX] = { | 81 | const char *compute_names[COMPUTE_MAX] = { |
| 80 | [COMPUTE_DELTA] = "delta", | 82 | [COMPUTE_DELTA] = "delta", |
| 83 | [COMPUTE_DELTA_ABS] = "delta-abs", | ||
| 81 | [COMPUTE_RATIO] = "ratio", | 84 | [COMPUTE_RATIO] = "ratio", |
| 82 | [COMPUTE_WEIGHTED_DIFF] = "wdiff", | 85 | [COMPUTE_WEIGHTED_DIFF] = "wdiff", |
| 83 | }; | 86 | }; |
| @@ -86,6 +89,7 @@ static int compute; | |||
| 86 | 89 | ||
| 87 | static int compute_2_hpp[COMPUTE_MAX] = { | 90 | static int compute_2_hpp[COMPUTE_MAX] = { |
| 88 | [COMPUTE_DELTA] = PERF_HPP_DIFF__DELTA, | 91 | [COMPUTE_DELTA] = PERF_HPP_DIFF__DELTA, |
| 92 | [COMPUTE_DELTA_ABS] = PERF_HPP_DIFF__DELTA_ABS, | ||
| 89 | [COMPUTE_RATIO] = PERF_HPP_DIFF__RATIO, | 93 | [COMPUTE_RATIO] = PERF_HPP_DIFF__RATIO, |
| 90 | [COMPUTE_WEIGHTED_DIFF] = PERF_HPP_DIFF__WEIGHTED_DIFF, | 94 | [COMPUTE_WEIGHTED_DIFF] = PERF_HPP_DIFF__WEIGHTED_DIFF, |
| 91 | }; | 95 | }; |
| @@ -111,6 +115,10 @@ static struct header_column { | |||
| 111 | .name = "Delta", | 115 | .name = "Delta", |
| 112 | .width = 7, | 116 | .width = 7, |
| 113 | }, | 117 | }, |
| 118 | [PERF_HPP_DIFF__DELTA_ABS] = { | ||
| 119 | .name = "Delta Abs", | ||
| 120 | .width = 7, | ||
| 121 | }, | ||
| 114 | [PERF_HPP_DIFF__RATIO] = { | 122 | [PERF_HPP_DIFF__RATIO] = { |
| 115 | .name = "Ratio", | 123 | .name = "Ratio", |
| 116 | .width = 14, | 124 | .width = 14, |
| @@ -298,6 +306,7 @@ static int formula_fprintf(struct hist_entry *he, struct hist_entry *pair, | |||
| 298 | { | 306 | { |
| 299 | switch (compute) { | 307 | switch (compute) { |
| 300 | case COMPUTE_DELTA: | 308 | case COMPUTE_DELTA: |
| 309 | case COMPUTE_DELTA_ABS: | ||
| 301 | return formula_delta(he, pair, buf, size); | 310 | return formula_delta(he, pair, buf, size); |
| 302 | case COMPUTE_RATIO: | 311 | case COMPUTE_RATIO: |
| 303 | return formula_ratio(he, pair, buf, size); | 312 | return formula_ratio(he, pair, buf, size); |
| @@ -461,6 +470,7 @@ static void hists__precompute(struct hists *hists) | |||
| 461 | 470 | ||
| 462 | switch (compute) { | 471 | switch (compute) { |
| 463 | case COMPUTE_DELTA: | 472 | case COMPUTE_DELTA: |
| 473 | case COMPUTE_DELTA_ABS: | ||
| 464 | compute_delta(he, pair); | 474 | compute_delta(he, pair); |
| 465 | break; | 475 | break; |
| 466 | case COMPUTE_RATIO: | 476 | case COMPUTE_RATIO: |
| @@ -498,6 +508,13 @@ __hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right, | |||
| 498 | 508 | ||
| 499 | return cmp_doubles(l, r); | 509 | return cmp_doubles(l, r); |
| 500 | } | 510 | } |
| 511 | case COMPUTE_DELTA_ABS: | ||
| 512 | { | ||
| 513 | double l = fabs(left->diff.period_ratio_delta); | ||
| 514 | double r = fabs(right->diff.period_ratio_delta); | ||
| 515 | |||
| 516 | return cmp_doubles(l, r); | ||
| 517 | } | ||
| 501 | case COMPUTE_RATIO: | 518 | case COMPUTE_RATIO: |
| 502 | { | 519 | { |
| 503 | double l = left->diff.period_ratio; | 520 | double l = left->diff.period_ratio; |
| @@ -564,7 +581,7 @@ hist_entry__cmp_compute_idx(struct hist_entry *left, struct hist_entry *right, | |||
| 564 | if (!p_left || !p_right) | 581 | if (!p_left || !p_right) |
| 565 | return p_left ? -1 : 1; | 582 | return p_left ? -1 : 1; |
| 566 | 583 | ||
| 567 | if (c != COMPUTE_DELTA) { | 584 | if (c != COMPUTE_DELTA && c != COMPUTE_DELTA_ABS) { |
| 568 | /* | 585 | /* |
| 569 | * The delta can be computed without the baseline, but | 586 | * The delta can be computed without the baseline, but |
| 570 | * others are not. Put those entries which have no | 587 | * others are not. Put those entries which have no |
| @@ -607,6 +624,15 @@ hist_entry__cmp_delta(struct perf_hpp_fmt *fmt, | |||
| 607 | } | 624 | } |
| 608 | 625 | ||
| 609 | static int64_t | 626 | static int64_t |
| 627 | hist_entry__cmp_delta_abs(struct perf_hpp_fmt *fmt, | ||
| 628 | struct hist_entry *left, struct hist_entry *right) | ||
| 629 | { | ||
| 630 | struct data__file *d = fmt_to_data_file(fmt); | ||
| 631 | |||
| 632 | return hist_entry__cmp_compute(right, left, COMPUTE_DELTA_ABS, d->idx); | ||
| 633 | } | ||
| 634 | |||
| 635 | static int64_t | ||
| 610 | hist_entry__cmp_ratio(struct perf_hpp_fmt *fmt, | 636 | hist_entry__cmp_ratio(struct perf_hpp_fmt *fmt, |
| 611 | struct hist_entry *left, struct hist_entry *right) | 637 | struct hist_entry *left, struct hist_entry *right) |
| 612 | { | 638 | { |
| @@ -633,6 +659,14 @@ hist_entry__cmp_delta_idx(struct perf_hpp_fmt *fmt __maybe_unused, | |||
| 633 | } | 659 | } |
| 634 | 660 | ||
| 635 | static int64_t | 661 | static int64_t |
| 662 | hist_entry__cmp_delta_abs_idx(struct perf_hpp_fmt *fmt __maybe_unused, | ||
| 663 | struct hist_entry *left, struct hist_entry *right) | ||
| 664 | { | ||
| 665 | return hist_entry__cmp_compute_idx(right, left, COMPUTE_DELTA_ABS, | ||
| 666 | sort_compute); | ||
| 667 | } | ||
| 668 | |||
| 669 | static int64_t | ||
| 636 | hist_entry__cmp_ratio_idx(struct perf_hpp_fmt *fmt __maybe_unused, | 670 | hist_entry__cmp_ratio_idx(struct perf_hpp_fmt *fmt __maybe_unused, |
| 637 | struct hist_entry *left, struct hist_entry *right) | 671 | struct hist_entry *left, struct hist_entry *right) |
| 638 | { | 672 | { |
| @@ -775,7 +809,7 @@ static const struct option options[] = { | |||
| 775 | OPT_BOOLEAN('b', "baseline-only", &show_baseline_only, | 809 | OPT_BOOLEAN('b', "baseline-only", &show_baseline_only, |
| 776 | "Show only items with match in baseline"), | 810 | "Show only items with match in baseline"), |
| 777 | OPT_CALLBACK('c', "compute", &compute, | 811 | OPT_CALLBACK('c', "compute", &compute, |
| 778 | "delta,ratio,wdiff:w1,w2 (default delta)", | 812 | "delta,delta-abs,ratio,wdiff:w1,w2 (default delta)", |
| 779 | "Entries differential computation selection", | 813 | "Entries differential computation selection", |
| 780 | setup_compute), | 814 | setup_compute), |
| 781 | OPT_BOOLEAN('p', "period", &show_period, | 815 | OPT_BOOLEAN('p', "period", &show_period, |
| @@ -945,6 +979,7 @@ hpp__entry_pair(struct hist_entry *he, struct hist_entry *pair, | |||
| 945 | 979 | ||
| 946 | switch (idx) { | 980 | switch (idx) { |
| 947 | case PERF_HPP_DIFF__DELTA: | 981 | case PERF_HPP_DIFF__DELTA: |
| 982 | case PERF_HPP_DIFF__DELTA_ABS: | ||
| 948 | if (pair->diff.computed) | 983 | if (pair->diff.computed) |
| 949 | diff = pair->diff.period_ratio_delta; | 984 | diff = pair->diff.period_ratio_delta; |
| 950 | else | 985 | else |
| @@ -1118,6 +1153,10 @@ static void data__hpp_register(struct data__file *d, int idx) | |||
| 1118 | fmt->color = hpp__color_wdiff; | 1153 | fmt->color = hpp__color_wdiff; |
| 1119 | fmt->sort = hist_entry__cmp_wdiff; | 1154 | fmt->sort = hist_entry__cmp_wdiff; |
| 1120 | break; | 1155 | break; |
| 1156 | case PERF_HPP_DIFF__DELTA_ABS: | ||
| 1157 | fmt->color = hpp__color_delta; | ||
| 1158 | fmt->sort = hist_entry__cmp_delta_abs; | ||
| 1159 | break; | ||
| 1121 | default: | 1160 | default: |
| 1122 | fmt->sort = hist_entry__cmp_nop; | 1161 | fmt->sort = hist_entry__cmp_nop; |
| 1123 | break; | 1162 | break; |
| @@ -1195,6 +1234,9 @@ static int ui_init(void) | |||
| 1195 | case COMPUTE_WEIGHTED_DIFF: | 1234 | case COMPUTE_WEIGHTED_DIFF: |
| 1196 | fmt->sort = hist_entry__cmp_wdiff_idx; | 1235 | fmt->sort = hist_entry__cmp_wdiff_idx; |
| 1197 | break; | 1236 | break; |
| 1237 | case COMPUTE_DELTA_ABS: | ||
| 1238 | fmt->sort = hist_entry__cmp_delta_abs_idx; | ||
| 1239 | break; | ||
| 1198 | default: | 1240 | default: |
| 1199 | BUG_ON(1); | 1241 | BUG_ON(1); |
| 1200 | } | 1242 | } |
