Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1621811 > unrolled thread

[tip:perf/core] perf stat: Refactor the code to strip csv output with ltrim()

Started bytip-bot for Taeung Song <tipbot@zytor.com>
First post2017-04-12 07:50 +0200
Last post2017-04-12 07:50 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [tip:perf/core] perf stat: Refactor the code to strip csv output  with ltrim() tip-bot for Taeung Song <tipbot@zytor.com> - 2017-04-12 07:50 +0200

#1621811 — [tip:perf/core] perf stat: Refactor the code to strip csv output with ltrim()

Fromtip-bot for Taeung Song <tipbot@zytor.com>
Date2017-04-12 07:50 +0200
Subject[tip:perf/core] perf stat: Refactor the code to strip csv output with ltrim()
Message-ID<tvjke-Bv-11@gated-at.bofh.it>
Commit-ID:  b07c40df1f4e6f937271921cb116d570bb9c4a31
Gitweb:     http://git.kernel.org/tip/b07c40df1f4e6f937271921cb116d570bb9c4a31
Author:     Taeung Song <treeze.taeung@gmail.com>
AuthorDate: Fri, 7 Apr 2017 23:24:18 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 11 Apr 2017 08:45:10 -0300

perf stat: Refactor the code to strip csv output with ltrim()

To strip csv output, use ltrim() instead of just while loop and
isspace() at print_metric_{only}_csv().

Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1491575061-704-3-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-stat.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 2158ea1..868e086a 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -875,10 +875,7 @@ static void print_metric_csv(void *ctx,
 		return;
 	}
 	snprintf(buf, sizeof(buf), fmt, val);
-	vals = buf;
-	while (isspace(*vals))
-		vals++;
-	ends = vals;
+	ends = vals = ltrim(buf);
 	while (isdigit(*ends) || *ends == '.')
 		ends++;
 	*ends = 0;
@@ -950,10 +947,7 @@ static void print_metric_only_csv(void *ctx, const char *color __maybe_unused,
 		return;
 	unit = fixunit(tbuf, os->evsel, unit);
 	snprintf(buf, sizeof buf, fmt, val);
-	vals = buf;
-	while (isspace(*vals))
-		vals++;
-	ends = vals;
+	ends = vals = ltrim(buf);
 	while (isdigit(*ends) || *ends == '.')
 		ends++;
 	*ends = 0;

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web