diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-05-11 21:06:18 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-05-21 05:45:37 -0400 |
commit | 4e754e1c7fe02e6b104e61f7e06e9895527e8ad3 (patch) | |
tree | 22ace85da5cb4d4914f8204bbc90a3eead4886a8 /tools/perf/tests | |
parent | 1c89fe9b0447f0ce393325e51911f8073432b7b4 (diff) |
perf tests: Factor out print_hists_*()
Those print helper functions can be reused by later hist test cases so
factor them out to a common location.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1400480762-22852-20-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools/perf/tests')
-rw-r--r-- | tools/perf/tests/hists_common.c | 57 | ||||
-rw-r--r-- | tools/perf/tests/hists_common.h | 3 | ||||
-rw-r--r-- | tools/perf/tests/hists_filter.c | 37 | ||||
-rw-r--r-- | tools/perf/tests/hists_link.c | 29 |
4 files changed, 66 insertions, 60 deletions
diff --git a/tools/perf/tests/hists_common.c b/tools/perf/tests/hists_common.c index 44655b395bb9..040a85b17aee 100644 --- a/tools/perf/tests/hists_common.c +++ b/tools/perf/tests/hists_common.c | |||
@@ -146,3 +146,60 @@ out: | |||
146 | machine__delete(machine); | 146 | machine__delete(machine); |
147 | return NULL; | 147 | return NULL; |
148 | } | 148 | } |
149 | |||
150 | void print_hists_in(struct hists *hists) | ||
151 | { | ||
152 | int i = 0; | ||
153 | struct rb_root *root; | ||
154 | struct rb_node *node; | ||
155 | |||
156 | if (sort__need_collapse) | ||
157 | root = &hists->entries_collapsed; | ||
158 | else | ||
159 | root = hists->entries_in; | ||
160 | |||
161 | pr_info("----- %s --------\n", __func__); | ||
162 | node = rb_first(root); | ||
163 | while (node) { | ||
164 | struct hist_entry *he; | ||
165 | |||
166 | he = rb_entry(node, struct hist_entry, rb_node_in); | ||
167 | |||
168 | if (!he->filtered) { | ||
169 | pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n", | ||
170 | i, thread__comm_str(he->thread), | ||
171 | he->ms.map->dso->short_name, | ||
172 | he->ms.sym->name, he->stat.period); | ||
173 | } | ||
174 | |||
175 | i++; | ||
176 | node = rb_next(node); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | void print_hists_out(struct hists *hists) | ||
181 | { | ||
182 | int i = 0; | ||
183 | struct rb_root *root; | ||
184 | struct rb_node *node; | ||
185 | |||
186 | root = &hists->entries; | ||
187 | |||
188 | pr_info("----- %s --------\n", __func__); | ||
189 | node = rb_first(root); | ||
190 | while (node) { | ||
191 | struct hist_entry *he; | ||
192 | |||
193 | he = rb_entry(node, struct hist_entry, rb_node); | ||
194 | |||
195 | if (!he->filtered) { | ||
196 | pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n", | ||
197 | i, thread__comm_str(he->thread), | ||
198 | he->ms.map->dso->short_name, | ||
199 | he->ms.sym->name, he->stat.period); | ||
200 | } | ||
201 | |||
202 | i++; | ||
203 | node = rb_next(node); | ||
204 | } | ||
205 | } | ||
diff --git a/tools/perf/tests/hists_common.h b/tools/perf/tests/hists_common.h index 2528b8fc105a..1415ae69d7b6 100644 --- a/tools/perf/tests/hists_common.h +++ b/tools/perf/tests/hists_common.h | |||
@@ -41,4 +41,7 @@ struct machines; | |||
41 | */ | 41 | */ |
42 | struct machine *setup_fake_machine(struct machines *machines); | 42 | struct machine *setup_fake_machine(struct machines *machines); |
43 | 43 | ||
44 | void print_hists_in(struct hists *hists); | ||
45 | void print_hists_out(struct hists *hists); | ||
46 | |||
44 | #endif /* __PERF_TESTS__HISTS_COMMON_H__ */ | 47 | #endif /* __PERF_TESTS__HISTS_COMMON_H__ */ |
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c index 4617a8bee29b..13c8cf49225e 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c | |||
@@ -98,33 +98,6 @@ out: | |||
98 | return TEST_FAIL; | 98 | return TEST_FAIL; |
99 | } | 99 | } |
100 | 100 | ||
101 | static void print_hists(struct hists *hists) | ||
102 | { | ||
103 | int i = 0; | ||
104 | struct rb_root *root; | ||
105 | struct rb_node *node; | ||
106 | |||
107 | root = &hists->entries; | ||
108 | |||
109 | pr_info("----- %s --------\n", __func__); | ||
110 | node = rb_first(root); | ||
111 | while (node) { | ||
112 | struct hist_entry *he; | ||
113 | |||
114 | he = rb_entry(node, struct hist_entry, rb_node); | ||
115 | |||
116 | if (!he->filtered) { | ||
117 | pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n", | ||
118 | i, thread__comm_str(he->thread), | ||
119 | he->ms.map->dso->short_name, | ||
120 | he->ms.sym->name, he->stat.period); | ||
121 | } | ||
122 | |||
123 | i++; | ||
124 | node = rb_next(node); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | int test__hists_filter(void) | 101 | int test__hists_filter(void) |
129 | { | 102 | { |
130 | int err = TEST_FAIL; | 103 | int err = TEST_FAIL; |
@@ -169,7 +142,7 @@ int test__hists_filter(void) | |||
169 | 142 | ||
170 | if (verbose > 2) { | 143 | if (verbose > 2) { |
171 | pr_info("Normal histogram\n"); | 144 | pr_info("Normal histogram\n"); |
172 | print_hists(hists); | 145 | print_hists_out(hists); |
173 | } | 146 | } |
174 | 147 | ||
175 | TEST_ASSERT_VAL("Invalid nr samples", | 148 | TEST_ASSERT_VAL("Invalid nr samples", |
@@ -193,7 +166,7 @@ int test__hists_filter(void) | |||
193 | 166 | ||
194 | if (verbose > 2) { | 167 | if (verbose > 2) { |
195 | pr_info("Histogram for thread filter\n"); | 168 | pr_info("Histogram for thread filter\n"); |
196 | print_hists(hists); | 169 | print_hists_out(hists); |
197 | } | 170 | } |
198 | 171 | ||
199 | /* normal stats should be invariant */ | 172 | /* normal stats should be invariant */ |
@@ -222,7 +195,7 @@ int test__hists_filter(void) | |||
222 | 195 | ||
223 | if (verbose > 2) { | 196 | if (verbose > 2) { |
224 | pr_info("Histogram for dso filter\n"); | 197 | pr_info("Histogram for dso filter\n"); |
225 | print_hists(hists); | 198 | print_hists_out(hists); |
226 | } | 199 | } |
227 | 200 | ||
228 | /* normal stats should be invariant */ | 201 | /* normal stats should be invariant */ |
@@ -257,7 +230,7 @@ int test__hists_filter(void) | |||
257 | 230 | ||
258 | if (verbose > 2) { | 231 | if (verbose > 2) { |
259 | pr_info("Histogram for symbol filter\n"); | 232 | pr_info("Histogram for symbol filter\n"); |
260 | print_hists(hists); | 233 | print_hists_out(hists); |
261 | } | 234 | } |
262 | 235 | ||
263 | /* normal stats should be invariant */ | 236 | /* normal stats should be invariant */ |
@@ -284,7 +257,7 @@ int test__hists_filter(void) | |||
284 | 257 | ||
285 | if (verbose > 2) { | 258 | if (verbose > 2) { |
286 | pr_info("Histogram for all filters\n"); | 259 | pr_info("Histogram for all filters\n"); |
287 | print_hists(hists); | 260 | print_hists_out(hists); |
288 | } | 261 | } |
289 | 262 | ||
290 | /* normal stats should be invariant */ | 263 | /* normal stats should be invariant */ |
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index b009bbf440d9..4e783db60bba 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c | |||
@@ -268,33 +268,6 @@ static int validate_link(struct hists *leader, struct hists *other) | |||
268 | return __validate_link(leader, 0) || __validate_link(other, 1); | 268 | return __validate_link(leader, 0) || __validate_link(other, 1); |
269 | } | 269 | } |
270 | 270 | ||
271 | static void print_hists(struct hists *hists) | ||
272 | { | ||
273 | int i = 0; | ||
274 | struct rb_root *root; | ||
275 | struct rb_node *node; | ||
276 | |||
277 | if (sort__need_collapse) | ||
278 | root = &hists->entries_collapsed; | ||
279 | else | ||
280 | root = hists->entries_in; | ||
281 | |||
282 | pr_info("----- %s --------\n", __func__); | ||
283 | node = rb_first(root); | ||
284 | while (node) { | ||
285 | struct hist_entry *he; | ||
286 | |||
287 | he = rb_entry(node, struct hist_entry, rb_node_in); | ||
288 | |||
289 | pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n", | ||
290 | i, thread__comm_str(he->thread), he->ms.map->dso->short_name, | ||
291 | he->ms.sym->name, he->stat.period); | ||
292 | |||
293 | i++; | ||
294 | node = rb_next(node); | ||
295 | } | ||
296 | } | ||
297 | |||
298 | int test__hists_link(void) | 271 | int test__hists_link(void) |
299 | { | 272 | { |
300 | int err = -1; | 273 | int err = -1; |
@@ -336,7 +309,7 @@ int test__hists_link(void) | |||
336 | hists__collapse_resort(&evsel->hists, NULL); | 309 | hists__collapse_resort(&evsel->hists, NULL); |
337 | 310 | ||
338 | if (verbose > 2) | 311 | if (verbose > 2) |
339 | print_hists(&evsel->hists); | 312 | print_hists_in(&evsel->hists); |
340 | } | 313 | } |
341 | 314 | ||
342 | first = perf_evlist__first(evlist); | 315 | first = perf_evlist__first(evlist); |