aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-05-14 13:19:35 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-05-14 13:19:35 -0400
commitc82ee828aa20487d254a5225d256cd422acee459 (patch)
tree6f8132442237bc4f2393e04a5f30b3711a8f91ca /tools/perf/builtin-report.c
parentcee75ac7ecc27084accdb9d9d6fde65a09f047ae (diff)
perf report: Report number of events, not samples
Number of samples is meaningless after we switched to auto-freq, so report the number of events, i.e. not the sum of the different periods, but the number PERF_RECORD_SAMPLE emitted by the kernel. While doing this I noticed that naming "count" to the sum of all the event periods can be confusing, so rename it to .period, just like in struct sample.data, so that we become more consistent. This helps with the next step, that was to record in struct hist_entry the number of sample events for each instance, we need that because we use it to generate the number of events when applying filters to the tree of hist entries like it is being done in the TUI report browser. Suggested-by: Ingo Molnar <mingo@elte.hu> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index b8f47ded6287..68265120ee07 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -188,14 +188,14 @@ static int process_sample_event(event_t *event, struct perf_session *session)
188 return 0; 188 return 0;
189 189
190 if (perf_session__add_hist_entry(session, &al, &data)) { 190 if (perf_session__add_hist_entry(session, &al, &data)) {
191 pr_debug("problem incrementing symbol count, skipping event\n"); 191 pr_debug("problem incrementing symbol period, skipping event\n");
192 return -1; 192 return -1;
193 } 193 }
194 194
195 attr = perf_header__find_attr(data.id, &session->header); 195 attr = perf_header__find_attr(data.id, &session->header);
196 196
197 if (add_event_total(session, &data, attr)) { 197 if (add_event_total(session, &data, attr)) {
198 pr_debug("problem adding event count\n"); 198 pr_debug("problem adding event period\n");
199 return -1; 199 return -1;
200 } 200 }
201 201
@@ -269,11 +269,25 @@ static struct perf_event_ops event_ops = {
269 269
270extern volatile int session_done; 270extern volatile int session_done;
271 271
272static void sig_handler(int sig __attribute__((__unused__))) 272static void sig_handler(int sig __used)
273{ 273{
274 session_done = 1; 274 session_done = 1;
275} 275}
276 276
277static 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
277static int __cmd_report(void) 291static int __cmd_report(void)
278{ 292{
279 int ret = -EINVAL; 293 int ret = -EINVAL;
@@ -319,14 +333,12 @@ static int __cmd_report(void)
319 if (use_browser) 333 if (use_browser)
320 hists__browse(hists, help, input_name); 334 hists__browse(hists, help, input_name);
321 else { 335 else {
322 if (rb_first(&session->hists.entries) == 336 const char *evname = NULL;
337 if (rb_first(&session->hists.entries) !=
323 rb_last(&session->hists.entries)) 338 rb_last(&session->hists.entries))
324 fprintf(stdout, "# Samples: %Ld\n#\n", 339 evname = __event_name(hists->type, hists->config);
325 hists->stats.total_period); 340
326 else 341 hists__fprintf_nr_sample_events(hists, evname, stdout);
327 fprintf(stdout, "# Samples: %Ld %s\n#\n",
328 hists->stats.total_period,
329 __event_name(hists->type, hists->config));
330 342
331 hists__fprintf(hists, NULL, false, stdout); 343 hists__fprintf(hists, NULL, false, stdout);
332 fprintf(stdout, "\n\n"); 344 fprintf(stdout, "\n\n");