Skip to content

Commit 40480a8

Browse files
Jin Yaoacmel
authored andcommitted
perf stat: Factor out aggregate counts printing
Move the aggregate counts printing to a new function print_counter_aggrdata, which will be used in following patches. Signed-off-by: Jin Yao <[email protected]> Tested-by: Ravi Bangoria <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Jin Yao <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 064b4e8 commit 40480a8

File tree

1 file changed

+39
-25
lines changed

1 file changed

+39
-25
lines changed

tools/perf/util/stat-display.c

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -594,16 +594,49 @@ static void aggr_cb(struct perf_stat_config *config,
594594
}
595595
}
596596

597+
static 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+
597632
static void print_aggr(struct perf_stat_config *config,
598633
struct perf_evlist *evlist,
599634
char *prefix)
600635
{
601636
bool metric_only = config->metric_only;
602637
FILE *output = config->output;
603638
struct perf_evsel *counter;
604-
int s, id, nr;
605-
double uval;
606-
u64 ena, run, val;
639+
int s;
607640
bool first;
608641

609642
if (!(config->aggr_map || config->aggr_get_id))
@@ -616,33 +649,14 @@ static void print_aggr(struct perf_stat_config *config,
616649
* Without each counter has its own line.
617650
*/
618651
for (s = 0; s < config->aggr_map->nr; s++) {
619-
struct aggr_data ad;
620652
if (prefix && metric_only)
621653
fprintf(output, "%s", prefix);
622654

623-
ad.id = id = config->aggr_map->map[s];
624655
first = true;
625656
evlist__for_each_entry(evlist, counter) {
626-
ad.val = ad.ena = ad.run = 0;
627-
ad.nr = 0;
628-
if (!collect_data(config, counter, aggr_cb, &ad))
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);
657+
print_counter_aggrdata(config, counter, s,
658+
prefix, metric_only,
659+
&first);
646660
}
647661
if (metric_only)
648662
fputc('\n', output);

0 commit comments

Comments
 (0)