diff options
Diffstat (limited to 'tools/perf/builtin-diff.c')
| -rw-r--r-- | tools/perf/builtin-diff.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 1ce425d101a9..1fd96c13f199 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
| @@ -545,6 +545,42 @@ hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right, | |||
| 545 | return __hist_entry__cmp_compute(p_left, p_right, c); | 545 | return __hist_entry__cmp_compute(p_left, p_right, c); |
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | static int64_t | ||
| 549 | hist_entry__cmp_nop(struct hist_entry *left __maybe_unused, | ||
| 550 | struct hist_entry *right __maybe_unused) | ||
| 551 | { | ||
| 552 | return 0; | ||
| 553 | } | ||
| 554 | |||
| 555 | static int64_t | ||
| 556 | hist_entry__cmp_baseline(struct hist_entry *left, struct hist_entry *right) | ||
| 557 | { | ||
| 558 | if (sort_compute) | ||
| 559 | return 0; | ||
| 560 | |||
| 561 | if (left->stat.period == right->stat.period) | ||
| 562 | return 0; | ||
| 563 | return left->stat.period > right->stat.period ? 1 : -1; | ||
| 564 | } | ||
| 565 | |||
| 566 | static int64_t | ||
| 567 | hist_entry__cmp_delta(struct hist_entry *left, struct hist_entry *right) | ||
| 568 | { | ||
| 569 | return hist_entry__cmp_compute(right, left, COMPUTE_DELTA); | ||
| 570 | } | ||
| 571 | |||
| 572 | static int64_t | ||
| 573 | hist_entry__cmp_ratio(struct hist_entry *left, struct hist_entry *right) | ||
| 574 | { | ||
| 575 | return hist_entry__cmp_compute(right, left, COMPUTE_RATIO); | ||
| 576 | } | ||
| 577 | |||
| 578 | static int64_t | ||
| 579 | hist_entry__cmp_wdiff(struct hist_entry *left, struct hist_entry *right) | ||
| 580 | { | ||
| 581 | return hist_entry__cmp_compute(right, left, COMPUTE_WEIGHTED_DIFF); | ||
| 582 | } | ||
| 583 | |||
| 548 | static void insert_hist_entry_by_compute(struct rb_root *root, | 584 | static void insert_hist_entry_by_compute(struct rb_root *root, |
| 549 | struct hist_entry *he, | 585 | struct hist_entry *he, |
| 550 | int c) | 586 | int c) |
| @@ -605,7 +641,7 @@ static void hists__process(struct hists *hists) | |||
| 605 | hists__precompute(hists); | 641 | hists__precompute(hists); |
| 606 | hists__compute_resort(hists); | 642 | hists__compute_resort(hists); |
| 607 | } else { | 643 | } else { |
| 608 | hists__output_resort(hists); | 644 | hists__output_resort(hists, NULL); |
| 609 | } | 645 | } |
| 610 | 646 | ||
| 611 | hists__fprintf(hists, true, 0, 0, 0, stdout); | 647 | hists__fprintf(hists, true, 0, 0, 0, stdout); |
| @@ -1038,27 +1074,35 @@ static void data__hpp_register(struct data__file *d, int idx) | |||
| 1038 | fmt->header = hpp__header; | 1074 | fmt->header = hpp__header; |
| 1039 | fmt->width = hpp__width; | 1075 | fmt->width = hpp__width; |
| 1040 | fmt->entry = hpp__entry_global; | 1076 | fmt->entry = hpp__entry_global; |
| 1077 | fmt->cmp = hist_entry__cmp_nop; | ||
| 1078 | fmt->collapse = hist_entry__cmp_nop; | ||
| 1041 | 1079 | ||
| 1042 | /* TODO more colors */ | 1080 | /* TODO more colors */ |
| 1043 | switch (idx) { | 1081 | switch (idx) { |
| 1044 | case PERF_HPP_DIFF__BASELINE: | 1082 | case PERF_HPP_DIFF__BASELINE: |
| 1045 | fmt->color = hpp__color_baseline; | 1083 | fmt->color = hpp__color_baseline; |
| 1084 | fmt->sort = hist_entry__cmp_baseline; | ||
| 1046 | break; | 1085 | break; |
| 1047 | case PERF_HPP_DIFF__DELTA: | 1086 | case PERF_HPP_DIFF__DELTA: |
| 1048 | fmt->color = hpp__color_delta; | 1087 | fmt->color = hpp__color_delta; |
| 1088 | fmt->sort = hist_entry__cmp_delta; | ||
| 1049 | break; | 1089 | break; |
| 1050 | case PERF_HPP_DIFF__RATIO: | 1090 | case PERF_HPP_DIFF__RATIO: |
| 1051 | fmt->color = hpp__color_ratio; | 1091 | fmt->color = hpp__color_ratio; |
| 1092 | fmt->sort = hist_entry__cmp_ratio; | ||
| 1052 | break; | 1093 | break; |
| 1053 | case PERF_HPP_DIFF__WEIGHTED_DIFF: | 1094 | case PERF_HPP_DIFF__WEIGHTED_DIFF: |
| 1054 | fmt->color = hpp__color_wdiff; | 1095 | fmt->color = hpp__color_wdiff; |
| 1096 | fmt->sort = hist_entry__cmp_wdiff; | ||
| 1055 | break; | 1097 | break; |
| 1056 | default: | 1098 | default: |
| 1099 | fmt->sort = hist_entry__cmp_nop; | ||
| 1057 | break; | 1100 | break; |
| 1058 | } | 1101 | } |
| 1059 | 1102 | ||
| 1060 | init_header(d, dfmt); | 1103 | init_header(d, dfmt); |
| 1061 | perf_hpp__column_register(fmt); | 1104 | perf_hpp__column_register(fmt); |
| 1105 | perf_hpp__register_sort_field(fmt); | ||
| 1062 | } | 1106 | } |
| 1063 | 1107 | ||
| 1064 | static void ui_init(void) | 1108 | static void ui_init(void) |
