lkml.org 
[lkml]   [2018]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf stat: fix cvs output format
On Mon, Mar 05, 2018 at 10:43:53PM -0800, Cong Wang wrote:
> From: Ilya Pronin <ipronin@twitter.com>
>
> When printing stats in CSV mode, perf stat appends extra CSV
> separators when counter is not supported:
>
> <not supported>,,L1-dcache-store-misses,mesos/bd442f34-2b4a-47df-b966-9b281f9f56fc,0,100.00,,,,
>
> which causes a failure of parsing fields. The numbers of separators
> is fixed for each line, no matter supported or not supported.
>
> Fixes: 92a61f6412d3 ("perf stat: Implement CSV metrics output")
> Cc: Andi Kleen <ak@linux.intel.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Signed-off-by: Ilya Pronin <ipronin@twitter.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> ---
> tools/perf/builtin-stat.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 98bf9d32f222..54a4c152edb3 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -917,7 +917,7 @@ static void print_metric_csv(void *ctx,
> char buf[64], *vals, *ends;
>
> if (unit == NULL || fmt == NULL) {
> - fprintf(out, "%s%s%s%s", csv_sep, csv_sep, csv_sep, csv_sep);
> + fprintf(out, "%s%s", csv_sep, csv_sep);
> return;
> }

right, the non else legs prints just 2 values:
fprintf(out, "%s%s%s%s", csv_sep, vals, csv_sep, unit);

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

\
 
 \ /
  Last update: 2018-03-06 08:59    [W:0.107 / U:0.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site