diff options
Diffstat (limited to 'tools/perf/builtin-diff.c')
-rw-r--r-- | tools/perf/builtin-diff.c | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 8c5c11ca8c53..1fd96c13f199 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -357,6 +357,7 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused, | |||
357 | static struct perf_tool tool = { | 357 | static struct perf_tool tool = { |
358 | .sample = diff__process_sample_event, | 358 | .sample = diff__process_sample_event, |
359 | .mmap = perf_event__process_mmap, | 359 | .mmap = perf_event__process_mmap, |
360 | .mmap2 = perf_event__process_mmap2, | ||
360 | .comm = perf_event__process_comm, | 361 | .comm = perf_event__process_comm, |
361 | .exit = perf_event__process_exit, | 362 | .exit = perf_event__process_exit, |
362 | .fork = perf_event__process_fork, | 363 | .fork = perf_event__process_fork, |
@@ -544,6 +545,42 @@ hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right, | |||
544 | return __hist_entry__cmp_compute(p_left, p_right, c); | 545 | return __hist_entry__cmp_compute(p_left, p_right, c); |
545 | } | 546 | } |
546 | 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 | |||
547 | static void insert_hist_entry_by_compute(struct rb_root *root, | 584 | static void insert_hist_entry_by_compute(struct rb_root *root, |
548 | struct hist_entry *he, | 585 | struct hist_entry *he, |
549 | int c) | 586 | int c) |
@@ -604,7 +641,7 @@ static void hists__process(struct hists *hists) | |||
604 | hists__precompute(hists); | 641 | hists__precompute(hists); |
605 | hists__compute_resort(hists); | 642 | hists__compute_resort(hists); |
606 | } else { | 643 | } else { |
607 | hists__output_resort(hists); | 644 | hists__output_resort(hists, NULL); |
608 | } | 645 | } |
609 | 646 | ||
610 | hists__fprintf(hists, true, 0, 0, 0, stdout); | 647 | hists__fprintf(hists, true, 0, 0, 0, stdout); |
@@ -1037,27 +1074,35 @@ static void data__hpp_register(struct data__file *d, int idx) | |||
1037 | fmt->header = hpp__header; | 1074 | fmt->header = hpp__header; |
1038 | fmt->width = hpp__width; | 1075 | fmt->width = hpp__width; |
1039 | 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; | ||
1040 | 1079 | ||
1041 | /* TODO more colors */ | 1080 | /* TODO more colors */ |
1042 | switch (idx) { | 1081 | switch (idx) { |
1043 | case PERF_HPP_DIFF__BASELINE: | 1082 | case PERF_HPP_DIFF__BASELINE: |
1044 | fmt->color = hpp__color_baseline; | 1083 | fmt->color = hpp__color_baseline; |
1084 | fmt->sort = hist_entry__cmp_baseline; | ||
1045 | break; | 1085 | break; |
1046 | case PERF_HPP_DIFF__DELTA: | 1086 | case PERF_HPP_DIFF__DELTA: |
1047 | fmt->color = hpp__color_delta; | 1087 | fmt->color = hpp__color_delta; |
1088 | fmt->sort = hist_entry__cmp_delta; | ||
1048 | break; | 1089 | break; |
1049 | case PERF_HPP_DIFF__RATIO: | 1090 | case PERF_HPP_DIFF__RATIO: |
1050 | fmt->color = hpp__color_ratio; | 1091 | fmt->color = hpp__color_ratio; |
1092 | fmt->sort = hist_entry__cmp_ratio; | ||
1051 | break; | 1093 | break; |
1052 | case PERF_HPP_DIFF__WEIGHTED_DIFF: | 1094 | case PERF_HPP_DIFF__WEIGHTED_DIFF: |
1053 | fmt->color = hpp__color_wdiff; | 1095 | fmt->color = hpp__color_wdiff; |
1096 | fmt->sort = hist_entry__cmp_wdiff; | ||
1054 | break; | 1097 | break; |
1055 | default: | 1098 | default: |
1099 | fmt->sort = hist_entry__cmp_nop; | ||
1056 | break; | 1100 | break; |
1057 | } | 1101 | } |
1058 | 1102 | ||
1059 | init_header(d, dfmt); | 1103 | init_header(d, dfmt); |
1060 | perf_hpp__column_register(fmt); | 1104 | perf_hpp__column_register(fmt); |
1105 | perf_hpp__register_sort_field(fmt); | ||
1061 | } | 1106 | } |
1062 | 1107 | ||
1063 | static void ui_init(void) | 1108 | static void ui_init(void) |
@@ -1142,6 +1187,11 @@ static int data_init(int argc, const char **argv) | |||
1142 | 1187 | ||
1143 | int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) | 1188 | int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) |
1144 | { | 1189 | { |
1190 | int ret = hists__init(); | ||
1191 | |||
1192 | if (ret < 0) | ||
1193 | return ret; | ||
1194 | |||
1145 | perf_config(perf_default_config, NULL); | 1195 | perf_config(perf_default_config, NULL); |
1146 | 1196 | ||
1147 | argc = parse_options(argc, argv, options, diff_usage, 0); | 1197 | argc = parse_options(argc, argv, options, diff_usage, 0); |