aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/stat-display.c64
1 files changed, 39 insertions, 25 deletions
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index 3324f23c7efc..f5b4ee79568c 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -594,6 +594,41 @@ static void aggr_cb(struct perf_stat_config *config,
594 } 594 }
595} 595}
596 596
597static void print_counter_aggrdata(struct perf_stat_config *config,
598 struct perf_evsel *counter, int s,
599 char *prefix, bool metric_only,
600 bool *first)
601{
602 struct aggr_data ad;
603 FILE *output = config->output;
604 u64 ena, run, val;
605 int id, nr;
606 double uval;
607
608 ad.id = id = config->aggr_map->map[s];
609 ad.val = ad.ena = ad.run = 0;
610 ad.nr = 0;
611 if (!collect_data(config, counter, aggr_cb, &ad))
612 return;
613
614 nr = ad.nr;
615 ena = ad.ena;
616 run = ad.run;
617 val = ad.val;
618 if (*first && metric_only) {
619 *first = false;
620 aggr_printout(config, counter, id, nr);
621 }
622 if (prefix && !metric_only)
623 fprintf(output, "%s", prefix);
624
625 uval = val * counter->scale;
626 printout(config, id, nr, counter, uval, prefix,
627 run, ena, 1.0, &rt_stat);
628 if (!metric_only)
629 fputc('\n', output);
630}
631
597static void print_aggr(struct perf_stat_config *config, 632static void print_aggr(struct perf_stat_config *config,
598 struct perf_evlist *evlist, 633 struct perf_evlist *evlist,
599 char *prefix) 634 char *prefix)
@@ -601,9 +636,7 @@ static void print_aggr(struct perf_stat_config *config,
601 bool metric_only = config->metric_only; 636 bool metric_only = config->metric_only;
602 FILE *output = config->output; 637 FILE *output = config->output;
603 struct perf_evsel *counter; 638 struct perf_evsel *counter;
604 int s, id, nr; 639 int s;
605 double uval;
606 u64 ena, run, val;
607 bool first; 640 bool first;
608 641
609 if (!(config->aggr_map || config->aggr_get_id)) 642 if (!(config->aggr_map || config->aggr_get_id))
@@ -616,33 +649,14 @@ static void print_aggr(struct perf_stat_config *config,
616 * Without each counter has its own line. 649 * Without each counter has its own line.
617 */ 650 */
618 for (s = 0; s < config->aggr_map->nr; s++) { 651 for (s = 0; s < config->aggr_map->nr; s++) {
619 struct aggr_data ad;
620 if (prefix && metric_only) 652 if (prefix && metric_only)
621 fprintf(output, "%s", prefix); 653 fprintf(output, "%s", prefix);
622 654
623 ad.id = id = config->aggr_map->map[s];
624 first = true; 655 first = true;
625 evlist__for_each_entry(evlist, counter) { 656 evlist__for_each_entry(evlist, counter) {
626 ad.val = ad.ena = ad.run = 0; 657 print_counter_aggrdata(config, counter, s,
627 ad.nr = 0; 658 prefix, metric_only,
628 if (!collect_data(config, counter, aggr_cb, &ad)) 659 &first);
629 continue;
630 nr = ad.nr;
631 ena = ad.ena;
632 run = ad.run;
633 val = ad.val;
634 if (first && metric_only) {
635 first = false;
636 aggr_printout(config, counter, id, nr);
637 }
638 if (prefix && !metric_only)
639 fprintf(output, "%s", prefix);
640
641 uval = val * counter->scale;
642 printout(config, id, nr, counter, uval, prefix,
643 run, ena, 1.0, &rt_stat);
644 if (!metric_only)
645 fputc('\n', output);
646 } 660 }
647 if (metric_only) 661 if (metric_only)
648 fputc('\n', output); 662 fputc('\n', output);