aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 39367609c707..2f91094e228b 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -86,17 +86,6 @@ static int report__config(const char *var, const char *value, void *cb)
86 return perf_default_config(var, value, cb); 86 return perf_default_config(var, value, cb);
87} 87}
88 88
89static void report__inc_stats(struct report *rep, struct hist_entry *he)
90{
91 /*
92 * The @he is either of a newly created one or an existing one
93 * merging current sample. We only want to count a new one so
94 * checking ->nr_events being 1.
95 */
96 if (he->stat.nr_events == 1)
97 rep->nr_entries++;
98}
99
100static int hist_iter__report_callback(struct hist_entry_iter *iter, 89static int hist_iter__report_callback(struct hist_entry_iter *iter,
101 struct addr_location *al, bool single, 90 struct addr_location *al, bool single,
102 void *arg) 91 void *arg)
@@ -108,8 +97,6 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
108 struct mem_info *mi; 97 struct mem_info *mi;
109 struct branch_info *bi; 98 struct branch_info *bi;
110 99
111 report__inc_stats(rep, he);
112
113 if (!ui__has_annotation()) 100 if (!ui__has_annotation())
114 return 0; 101 return 0;
115 102
@@ -457,6 +444,19 @@ static void report__collapse_hists(struct report *rep)
457 ui_progress__finish(); 444 ui_progress__finish();
458} 445}
459 446
447static void report__output_resort(struct report *rep)
448{
449 struct ui_progress prog;
450 struct perf_evsel *pos;
451
452 ui_progress__init(&prog, rep->nr_entries, "Sorting events for output...");
453
454 evlist__for_each(rep->session->evlist, pos)
455 hists__output_resort(evsel__hists(pos), &prog);
456
457 ui_progress__finish();
458}
459
460static int __cmd_report(struct report *rep) 460static int __cmd_report(struct report *rep)
461{ 461{
462 int ret; 462 int ret;
@@ -486,6 +486,9 @@ static int __cmd_report(struct report *rep)
486 486
487 report__warn_kptr_restrict(rep); 487 report__warn_kptr_restrict(rep);
488 488
489 evlist__for_each(session->evlist, pos)
490 rep->nr_entries += evsel__hists(pos)->nr_entries;
491
489 if (use_browser == 0) { 492 if (use_browser == 0) {
490 if (verbose > 3) 493 if (verbose > 3)
491 perf_session__fprintf(session, stdout); 494 perf_session__fprintf(session, stdout);
@@ -505,13 +508,20 @@ static int __cmd_report(struct report *rep)
505 if (session_done()) 508 if (session_done())
506 return 0; 509 return 0;
507 510
511 /*
512 * recalculate number of entries after collapsing since it
513 * might be changed during the collapse phase.
514 */
515 rep->nr_entries = 0;
516 evlist__for_each(session->evlist, pos)
517 rep->nr_entries += evsel__hists(pos)->nr_entries;
518
508 if (rep->nr_entries == 0) { 519 if (rep->nr_entries == 0) {
509 ui__error("The %s file has no samples!\n", file->path); 520 ui__error("The %s file has no samples!\n", file->path);
510 return 0; 521 return 0;
511 } 522 }
512 523
513 evlist__for_each(session->evlist, pos) 524 report__output_resort(rep);
514 hists__output_resort(evsel__hists(pos));
515 525
516 return report__browse_hists(rep); 526 return report__browse_hists(rep);
517} 527}