diff options
Diffstat (limited to 'tools/perf/builtin-diff.c')
-rw-r--r-- | tools/perf/builtin-diff.c | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 613a5c4f6d83..3a95a0260a5b 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -22,10 +22,10 @@ static char diff__default_sort_order[] = "dso,symbol"; | |||
22 | static bool force; | 22 | static bool force; |
23 | static bool show_displacement; | 23 | static bool show_displacement; |
24 | 24 | ||
25 | static int perf_session__add_hist_entry(struct perf_session *self, | 25 | static int hists__add_entry(struct hists *self, |
26 | struct addr_location *al, u64 count) | 26 | struct addr_location *al, u64 count) |
27 | { | 27 | { |
28 | if (__perf_session__add_hist_entry(&self->hists, al, NULL, count) != NULL) | 28 | if (__hists__add_entry(self, al, NULL, count) != NULL) |
29 | return 0; | 29 | return 0; |
30 | return -ENOMEM; | 30 | return -ENOMEM; |
31 | } | 31 | } |
@@ -49,12 +49,12 @@ static int diff__process_sample_event(event_t *event, struct perf_session *sessi | |||
49 | 49 | ||
50 | event__parse_sample(event, session->sample_type, &data); | 50 | event__parse_sample(event, session->sample_type, &data); |
51 | 51 | ||
52 | if (perf_session__add_hist_entry(session, &al, data.period)) { | 52 | if (hists__add_entry(&session->hists, &al, data.period)) { |
53 | pr_warning("problem incrementing symbol count, skipping event\n"); | 53 | pr_warning("problem incrementing symbol count, skipping event\n"); |
54 | return -1; | 54 | return -1; |
55 | } | 55 | } |
56 | 56 | ||
57 | session->events_stats.total += data.period; | 57 | session->hists.stats.total += data.period; |
58 | return 0; | 58 | return 0; |
59 | } | 59 | } |
60 | 60 | ||
@@ -87,35 +87,34 @@ static void perf_session__insert_hist_entry_by_name(struct rb_root *root, | |||
87 | rb_insert_color(&he->rb_node, root); | 87 | rb_insert_color(&he->rb_node, root); |
88 | } | 88 | } |
89 | 89 | ||
90 | static void perf_session__resort_hist_entries(struct perf_session *self) | 90 | static void hists__resort_entries(struct hists *self) |
91 | { | 91 | { |
92 | unsigned long position = 1; | 92 | unsigned long position = 1; |
93 | struct rb_root tmp = RB_ROOT; | 93 | struct rb_root tmp = RB_ROOT; |
94 | struct rb_node *next = rb_first(&self->hists); | 94 | struct rb_node *next = rb_first(&self->entries); |
95 | 95 | ||
96 | while (next != NULL) { | 96 | while (next != NULL) { |
97 | struct hist_entry *n = rb_entry(next, struct hist_entry, rb_node); | 97 | struct hist_entry *n = rb_entry(next, struct hist_entry, rb_node); |
98 | 98 | ||
99 | next = rb_next(&n->rb_node); | 99 | next = rb_next(&n->rb_node); |
100 | rb_erase(&n->rb_node, &self->hists); | 100 | rb_erase(&n->rb_node, &self->entries); |
101 | n->position = position++; | 101 | n->position = position++; |
102 | perf_session__insert_hist_entry_by_name(&tmp, n); | 102 | perf_session__insert_hist_entry_by_name(&tmp, n); |
103 | } | 103 | } |
104 | 104 | ||
105 | self->hists = tmp; | 105 | self->entries = tmp; |
106 | } | 106 | } |
107 | 107 | ||
108 | static void perf_session__set_hist_entries_positions(struct perf_session *self) | 108 | static void hists__set_positions(struct hists *self) |
109 | { | 109 | { |
110 | perf_session__output_resort(&self->hists, self->events_stats.total); | 110 | hists__output_resort(self); |
111 | perf_session__resort_hist_entries(self); | 111 | hists__resort_entries(self); |
112 | } | 112 | } |
113 | 113 | ||
114 | static struct hist_entry * | 114 | static struct hist_entry *hists__find_entry(struct hists *self, |
115 | perf_session__find_hist_entry(struct perf_session *self, | 115 | struct hist_entry *he) |
116 | struct hist_entry *he) | ||
117 | { | 116 | { |
118 | struct rb_node *n = self->hists.rb_node; | 117 | struct rb_node *n = self->entries.rb_node; |
119 | 118 | ||
120 | while (n) { | 119 | while (n) { |
121 | struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node); | 120 | struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node); |
@@ -132,14 +131,13 @@ perf_session__find_hist_entry(struct perf_session *self, | |||
132 | return NULL; | 131 | return NULL; |
133 | } | 132 | } |
134 | 133 | ||
135 | static void perf_session__match_hists(struct perf_session *old_session, | 134 | static void hists__match(struct hists *older, struct hists *newer) |
136 | struct perf_session *new_session) | ||
137 | { | 135 | { |
138 | struct rb_node *nd; | 136 | struct rb_node *nd; |
139 | 137 | ||
140 | for (nd = rb_first(&new_session->hists); nd; nd = rb_next(nd)) { | 138 | for (nd = rb_first(&newer->entries); nd; nd = rb_next(nd)) { |
141 | struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node); | 139 | struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node); |
142 | pos->pair = perf_session__find_hist_entry(old_session, pos); | 140 | pos->pair = hists__find_entry(older, pos); |
143 | } | 141 | } |
144 | } | 142 | } |
145 | 143 | ||
@@ -159,15 +157,13 @@ static int __cmd_diff(void) | |||
159 | goto out_delete; | 157 | goto out_delete; |
160 | } | 158 | } |
161 | 159 | ||
162 | perf_session__output_resort(&session[1]->hists, | 160 | hists__output_resort(&session[1]->hists); |
163 | session[1]->events_stats.total); | ||
164 | if (show_displacement) | 161 | if (show_displacement) |
165 | perf_session__set_hist_entries_positions(session[0]); | 162 | hists__set_positions(&session[0]->hists); |
166 | 163 | ||
167 | perf_session__match_hists(session[0], session[1]); | 164 | hists__match(&session[0]->hists, &session[1]->hists); |
168 | perf_session__fprintf_hists(&session[1]->hists, session[0], | 165 | hists__fprintf(&session[1]->hists, &session[0]->hists, |
169 | show_displacement, stdout, | 166 | show_displacement, stdout); |
170 | session[1]->events_stats.total); | ||
171 | out_delete: | 167 | out_delete: |
172 | for (i = 0; i < 2; ++i) | 168 | for (i = 0; i < 2; ++i) |
173 | perf_session__delete(session[i]); | 169 | perf_session__delete(session[i]); |