aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2018-06-06 18:15:09 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-06-07 15:01:44 -0400
commitc1a1f5d9da800dc715d8c1d8a9692c63c70c2955 (patch)
tree835bae2ebe69dc72fe086f6739e1107cfe04fb29
parentf515572734fb323aa0efe9ea2c546cd7fee327f7 (diff)
perf stat: Allow to specify specific metric column len
The following change will introduce new metrics, that doesn't need such wide hard coded spacing. Switch METRIC_ONLY_LEN macro usage with metric_only_len variable. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <frederic@kernel.org> Cc: Milian Wolff <milian.wolff@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/20180606221513.11302-7-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-stat.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 8f3fdc052728..3fc1f5286d50 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -145,6 +145,8 @@ static struct target target = {
145 145
146typedef int (*aggr_get_id_t)(struct cpu_map *m, int cpu); 146typedef int (*aggr_get_id_t)(struct cpu_map *m, int cpu);
147 147
148#define METRIC_ONLY_LEN 20
149
148static int run_count = 1; 150static int run_count = 1;
149static bool no_inherit = false; 151static bool no_inherit = false;
150static volatile pid_t child_pid = -1; 152static volatile pid_t child_pid = -1;
@@ -182,6 +184,7 @@ static int print_mixed_hw_group_error;
182static u64 *walltime_run; 184static u64 *walltime_run;
183static bool ru_display = false; 185static bool ru_display = false;
184static struct rusage ru_data; 186static struct rusage ru_data;
187static unsigned int metric_only_len = METRIC_ONLY_LEN;
185 188
186struct perf_stat { 189struct perf_stat {
187 bool record; 190 bool record;
@@ -969,8 +972,6 @@ static void print_metric_csv(void *ctx,
969 fprintf(out, "%s%s%s%s", csv_sep, vals, csv_sep, unit); 972 fprintf(out, "%s%s%s%s", csv_sep, vals, csv_sep, unit);
970} 973}
971 974
972#define METRIC_ONLY_LEN 20
973
974/* Filter out some columns that don't work well in metrics only mode */ 975/* Filter out some columns that don't work well in metrics only mode */
975 976
976static bool valid_only_metric(const char *unit) 977static bool valid_only_metric(const char *unit)
@@ -1002,7 +1003,7 @@ static void print_metric_only(void *ctx, const char *color, const char *fmt,
1002 struct outstate *os = ctx; 1003 struct outstate *os = ctx;
1003 FILE *out = os->fh; 1004 FILE *out = os->fh;
1004 char buf[1024], str[1024]; 1005 char buf[1024], str[1024];
1005 unsigned mlen = METRIC_ONLY_LEN; 1006 unsigned mlen = metric_only_len;
1006 1007
1007 if (!valid_only_metric(unit)) 1008 if (!valid_only_metric(unit))
1008 return; 1009 return;
@@ -1054,7 +1055,7 @@ static void print_metric_header(void *ctx, const char *color __maybe_unused,
1054 if (csv_output) 1055 if (csv_output)
1055 fprintf(os->fh, "%s%s", unit, csv_sep); 1056 fprintf(os->fh, "%s%s", unit, csv_sep);
1056 else 1057 else
1057 fprintf(os->fh, "%*s ", METRIC_ONLY_LEN, unit); 1058 fprintf(os->fh, "%*s ", metric_only_len, unit);
1058} 1059}
1059 1060
1060static void nsec_printout(int id, int nr, struct perf_evsel *evsel, double avg) 1061static void nsec_printout(int id, int nr, struct perf_evsel *evsel, double avg)