diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-03-03 00:14:03 -0500 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-05-21 05:45:34 -0400 |
commit | f156d84e427c9e1a855a4bb41156c7d82d87fb47 (patch) | |
tree | c5f570857be3a1a814822faf93fde5ccc6bee98e /tools/perf | |
parent | 093f0ef34c50ff5cca41c1e18e258ff688e915b6 (diff) |
perf tools: Support event grouping in hpp ->sort()
Move logic of hist_entry__sort_on_period to __hpp__sort() in order to
support event group report.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-5-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/ui/hist.c | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index a6eea666b443..0299385284fd 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -116,6 +116,62 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, | |||
116 | return ret; | 116 | return ret; |
117 | } | 117 | } |
118 | 118 | ||
119 | static int field_cmp(u64 field_a, u64 field_b) | ||
120 | { | ||
121 | if (field_a > field_b) | ||
122 | return 1; | ||
123 | if (field_a < field_b) | ||
124 | return -1; | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static int __hpp__sort(struct hist_entry *a, struct hist_entry *b, | ||
129 | hpp_field_fn get_field) | ||
130 | { | ||
131 | s64 ret; | ||
132 | int i, nr_members; | ||
133 | struct perf_evsel *evsel; | ||
134 | struct hist_entry *pair; | ||
135 | u64 *fields_a, *fields_b; | ||
136 | |||
137 | ret = field_cmp(get_field(a), get_field(b)); | ||
138 | if (ret || !symbol_conf.event_group) | ||
139 | return ret; | ||
140 | |||
141 | evsel = hists_to_evsel(a->hists); | ||
142 | if (!perf_evsel__is_group_event(evsel)) | ||
143 | return ret; | ||
144 | |||
145 | nr_members = evsel->nr_members; | ||
146 | fields_a = calloc(sizeof(*fields_a), nr_members); | ||
147 | fields_b = calloc(sizeof(*fields_b), nr_members); | ||
148 | |||
149 | if (!fields_a || !fields_b) | ||
150 | goto out; | ||
151 | |||
152 | list_for_each_entry(pair, &a->pairs.head, pairs.node) { | ||
153 | evsel = hists_to_evsel(pair->hists); | ||
154 | fields_a[perf_evsel__group_idx(evsel)] = get_field(pair); | ||
155 | } | ||
156 | |||
157 | list_for_each_entry(pair, &b->pairs.head, pairs.node) { | ||
158 | evsel = hists_to_evsel(pair->hists); | ||
159 | fields_b[perf_evsel__group_idx(evsel)] = get_field(pair); | ||
160 | } | ||
161 | |||
162 | for (i = 1; i < nr_members; i++) { | ||
163 | ret = field_cmp(fields_a[i], fields_b[i]); | ||
164 | if (ret) | ||
165 | break; | ||
166 | } | ||
167 | |||
168 | out: | ||
169 | free(fields_a); | ||
170 | free(fields_b); | ||
171 | |||
172 | return ret; | ||
173 | } | ||
174 | |||
119 | #define __HPP_HEADER_FN(_type, _str, _min_width, _unit_width) \ | 175 | #define __HPP_HEADER_FN(_type, _str, _min_width, _unit_width) \ |
120 | static int hpp__header_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ | 176 | static int hpp__header_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ |
121 | struct perf_hpp *hpp, \ | 177 | struct perf_hpp *hpp, \ |
@@ -195,9 +251,7 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused, \ | |||
195 | #define __HPP_SORT_FN(_type, _field) \ | 251 | #define __HPP_SORT_FN(_type, _field) \ |
196 | static int64_t hpp__sort_##_type(struct hist_entry *a, struct hist_entry *b) \ | 252 | static int64_t hpp__sort_##_type(struct hist_entry *a, struct hist_entry *b) \ |
197 | { \ | 253 | { \ |
198 | s64 __a = he_get_##_field(a); \ | 254 | return __hpp__sort(a, b, he_get_##_field); \ |
199 | s64 __b = he_get_##_field(b); \ | ||
200 | return __a - __b; \ | ||
201 | } | 255 | } |
202 | 256 | ||
203 | #define __HPP_ENTRY_RAW_FN(_type, _field) \ | 257 | #define __HPP_ENTRY_RAW_FN(_type, _field) \ |
@@ -217,9 +271,7 @@ static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused, \ | |||
217 | #define __HPP_SORT_RAW_FN(_type, _field) \ | 271 | #define __HPP_SORT_RAW_FN(_type, _field) \ |
218 | static int64_t hpp__sort_##_type(struct hist_entry *a, struct hist_entry *b) \ | 272 | static int64_t hpp__sort_##_type(struct hist_entry *a, struct hist_entry *b) \ |
219 | { \ | 273 | { \ |
220 | s64 __a = he_get_raw_##_field(a); \ | 274 | return __hpp__sort(a, b, he_get_raw_##_field); \ |
221 | s64 __b = he_get_raw_##_field(b); \ | ||
222 | return __a - __b; \ | ||
223 | } | 275 | } |
224 | 276 | ||
225 | 277 | ||