From 556b1fb7f9c1a9fd43ea4dacd5d14ec39ac6296a Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Wed, 3 Jun 2015 16:25:56 +0200 Subject: [PATCH] perf stat: Introduce print_shadow_stats function Move shadow counters display code into separate function as preparation for moving it into its own object. Signed-off-by: Jiri Olsa Cc: Andi Kleen Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1433341559-31848-7-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 72 +++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index fc85e6b..2ff2e22 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1059,43 +1059,11 @@ static void print_ll_cache_misses(int cpu, fprintf(output, " of all LL-cache hits "); } -static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg) +static void print_shadow_stats(struct perf_evsel *evsel, double avg, int cpu) { double total, ratio = 0.0, total2; - double sc = evsel->scale; - const char *fmt; - int cpu = cpu_map__id_to_cpu(id); int ctx = evsel_context(evsel); - if (csv_output) { - fmt = sc != 1.0 ? "%.2f%s" : "%.0f%s"; - } else { - if (big_num) - fmt = sc != 1.0 ? "%'18.2f%s" : "%'18.0f%s"; - else - fmt = sc != 1.0 ? "%18.2f%s" : "%18.0f%s"; - } - - aggr_printout(evsel, id, nr); - - if (aggr_mode == AGGR_GLOBAL) - cpu = 0; - - fprintf(output, fmt, avg, csv_sep); - - if (evsel->unit) - fprintf(output, "%-*s%s", - csv_output ? 0 : unit_width, - evsel->unit, csv_sep); - - fprintf(output, "%-*s", csv_output ? 0 : 25, perf_evsel__name(evsel)); - - if (evsel->cgrp) - fprintf(output, "%s%s", csv_sep, evsel->cgrp->name); - - if (csv_output || interval) - return; - if (perf_evsel__match(evsel, HARDWARE, HW_INSTRUCTIONS)) { total = avg_stats(&runtime_cycles_stats[ctx][cpu]); if (total) { @@ -1226,6 +1194,44 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg) } } +static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg) +{ + double sc = evsel->scale; + const char *fmt; + int cpu = cpu_map__id_to_cpu(id); + + if (csv_output) { + fmt = sc != 1.0 ? "%.2f%s" : "%.0f%s"; + } else { + if (big_num) + fmt = sc != 1.0 ? "%'18.2f%s" : "%'18.0f%s"; + else + fmt = sc != 1.0 ? "%18.2f%s" : "%18.0f%s"; + } + + aggr_printout(evsel, id, nr); + + if (aggr_mode == AGGR_GLOBAL) + cpu = 0; + + fprintf(output, fmt, avg, csv_sep); + + if (evsel->unit) + fprintf(output, "%-*s%s", + csv_output ? 0 : unit_width, + evsel->unit, csv_sep); + + fprintf(output, "%-*s", csv_output ? 0 : 25, perf_evsel__name(evsel)); + + if (evsel->cgrp) + fprintf(output, "%s%s", csv_sep, evsel->cgrp->name); + + if (csv_output || interval) + return; + + print_shadow_stats(evsel, avg, cpu); +} + static void print_aggr(char *prefix) { struct perf_evsel *counter; -- 2.7.4