diff options
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r-- | tools/perf/builtin-report.c | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 04de3387de3f..68265120ee07 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -138,8 +138,14 @@ static int add_event_total(struct perf_session *session, | |||
138 | if (!hists) | 138 | if (!hists) |
139 | return -ENOMEM; | 139 | return -ENOMEM; |
140 | 140 | ||
141 | hists->stats.total += data->period; | 141 | hists->stats.total_period += data->period; |
142 | session->hists.stats.total += data->period; | 142 | /* |
143 | * FIXME: add_event_total should be moved from here to | ||
144 | * perf_session__process_event so that the proper hist is passed to | ||
145 | * the event_op methods. | ||
146 | */ | ||
147 | hists__inc_nr_events(hists, PERF_RECORD_SAMPLE); | ||
148 | session->hists.stats.total_period += data->period; | ||
143 | return 0; | 149 | return 0; |
144 | } | 150 | } |
145 | 151 | ||
@@ -182,14 +188,14 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
182 | return 0; | 188 | return 0; |
183 | 189 | ||
184 | if (perf_session__add_hist_entry(session, &al, &data)) { | 190 | if (perf_session__add_hist_entry(session, &al, &data)) { |
185 | pr_debug("problem incrementing symbol count, skipping event\n"); | 191 | pr_debug("problem incrementing symbol period, skipping event\n"); |
186 | return -1; | 192 | return -1; |
187 | } | 193 | } |
188 | 194 | ||
189 | attr = perf_header__find_attr(data.id, &session->header); | 195 | attr = perf_header__find_attr(data.id, &session->header); |
190 | 196 | ||
191 | if (add_event_total(session, &data, attr)) { | 197 | if (add_event_total(session, &data, attr)) { |
192 | pr_debug("problem adding event count\n"); | 198 | pr_debug("problem adding event period\n"); |
193 | return -1; | 199 | return -1; |
194 | } | 200 | } |
195 | 201 | ||
@@ -263,11 +269,25 @@ static struct perf_event_ops event_ops = { | |||
263 | 269 | ||
264 | extern volatile int session_done; | 270 | extern volatile int session_done; |
265 | 271 | ||
266 | static void sig_handler(int sig __attribute__((__unused__))) | 272 | static void sig_handler(int sig __used) |
267 | { | 273 | { |
268 | session_done = 1; | 274 | session_done = 1; |
269 | } | 275 | } |
270 | 276 | ||
277 | static size_t hists__fprintf_nr_sample_events(struct hists *self, | ||
278 | const char *evname, FILE *fp) | ||
279 | { | ||
280 | size_t ret; | ||
281 | char unit; | ||
282 | unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE]; | ||
283 | |||
284 | nr_events = convert_unit(nr_events, &unit); | ||
285 | ret = fprintf(fp, "# Events: %lu%c", nr_events, unit); | ||
286 | if (evname != NULL) | ||
287 | ret += fprintf(fp, " %s", evname); | ||
288 | return ret + fprintf(fp, "\n#\n"); | ||
289 | } | ||
290 | |||
271 | static int __cmd_report(void) | 291 | static int __cmd_report(void) |
272 | { | 292 | { |
273 | int ret = -EINVAL; | 293 | int ret = -EINVAL; |
@@ -293,7 +313,7 @@ static int __cmd_report(void) | |||
293 | goto out_delete; | 313 | goto out_delete; |
294 | 314 | ||
295 | if (dump_trace) { | 315 | if (dump_trace) { |
296 | event__print_totals(); | 316 | perf_session__fprintf_nr_events(session, stdout); |
297 | goto out_delete; | 317 | goto out_delete; |
298 | } | 318 | } |
299 | 319 | ||
@@ -313,14 +333,12 @@ static int __cmd_report(void) | |||
313 | if (use_browser) | 333 | if (use_browser) |
314 | hists__browse(hists, help, input_name); | 334 | hists__browse(hists, help, input_name); |
315 | else { | 335 | else { |
316 | if (rb_first(&session->hists.entries) == | 336 | const char *evname = NULL; |
337 | if (rb_first(&session->hists.entries) != | ||
317 | rb_last(&session->hists.entries)) | 338 | rb_last(&session->hists.entries)) |
318 | fprintf(stdout, "# Samples: %Ld\n#\n", | 339 | evname = __event_name(hists->type, hists->config); |
319 | hists->stats.total); | 340 | |
320 | else | 341 | hists__fprintf_nr_sample_events(hists, evname, stdout); |
321 | fprintf(stdout, "# Samples: %Ld %s\n#\n", | ||
322 | hists->stats.total, | ||
323 | __event_name(hists->type, hists->config)); | ||
324 | 342 | ||
325 | hists__fprintf(hists, NULL, false, stdout); | 343 | hists__fprintf(hists, NULL, false, stdout); |
326 | fprintf(stdout, "\n\n"); | 344 | fprintf(stdout, "\n\n"); |