提交 df4f7b4d 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

perf stat: Move 'unit_width' to 'struct perf_stat_config'

Move the static 'unit_width' variable to 'struct perf_stat_config',
so it can be passed around and used outside the 'perf stat' command.
Signed-off-by: NJiri 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: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180830063252.23729-24-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 0ce5aa02
......@@ -161,7 +161,6 @@ static bool group = false;
static const char *pre_cmd = NULL;
static const char *post_cmd = NULL;
static bool sync_run = false;
static unsigned int unit_width = 4; /* strlen("unit") */
static bool forever = false;
static bool force_metric_only = false;
static bool no_merge = false;
......@@ -200,6 +199,7 @@ static volatile int done = 0;
static struct perf_stat_config stat_config = {
.aggr_mode = AGGR_GLOBAL,
.scale = true,
.unit_width = 4, /* strlen("unit") */
};
static bool is_duration_time(struct perf_evsel *evsel)
......@@ -524,8 +524,8 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
counter->supported = true;
l = strlen(counter->unit);
if (l > unit_width)
unit_width = l;
if (l > stat_config.unit_width)
stat_config.unit_width = l;
if (perf_evsel__should_store_id(counter) &&
perf_evsel__store_ids(counter, evsel_list))
......@@ -963,7 +963,7 @@ static void abs_printout(struct perf_stat_config *config,
if (evsel->unit)
fprintf(output, "%-*s%s",
config->csv_output ? 0 : unit_width,
config->csv_output ? 0 : config->unit_width,
evsel->unit, config->csv_sep);
fprintf(output, "%-*s", config->csv_output ? 0 : 25, perf_evsel__name(evsel));
......@@ -1056,7 +1056,7 @@ static void printout(struct perf_stat_config *config, int id, int nr,
}
fprintf(config->output, "%-*s%s",
config->csv_output ? 0 : unit_width,
config->csv_output ? 0 : config->unit_width,
counter->unit, config->csv_sep);
fprintf(config->output, "%*s",
......@@ -1542,6 +1542,7 @@ static void print_interval(struct perf_stat_config *config,
char *prefix, struct timespec *ts)
{
bool metric_only = config->metric_only;
unsigned int unit_width = config->unit_width;
FILE *output = config->output;
static int num_print_interval;
......
......@@ -98,6 +98,7 @@ struct perf_stat_config {
unsigned int interval;
unsigned int timeout;
unsigned int initial_delay;
unsigned int unit_width;
int times;
struct runtime_stat *stats;
int stats_num;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册