From: Namhyung Kim <namhyung....@lge.com>

perf bench prints header message for bench suite before starting the
benchmark.  However if the stdout is redirected to a file and bench
suite forks child processes this (and possibly other debugging
messages too) will be repeated multiple times.

  $ perf bench sched messaging
  # Running sched/messaging benchmark...
  # 20 sender and receiver processes per group
  # 10 groups == 400 processes run

       Total time: 0.100 [sec]

  $ perf bench sched messaging > result.txt
  $ wc -l result.txt
  391

In this file, there were so many "Running sched/messaging benchmark..."
lines.  This was because stdout is converted to fully-buffered due to
the redirection and inherited child processes.  Other lines are printed
after reaping all those tasks.

So fix it by flushing stdout before starting bench suites.

Signed-off-by: Namhyung Kim <namhy...@kernel.org>
Acked-by: Hitoshi Mitake <h.mit...@gmail.com>
Cc: Hitoshi Mitake <mit...@dcl.info.waseda.ac.jp>
Cc: Ingo Molnar <mi...@kernel.org>
Cc: Paul Mackerras <pau...@samba.org>
Cc: Peter Zijlstra <a.p.zijls...@chello.nl>
Link: 
http://lkml.kernel.org/r/1357637966-8216-1-git-send-email-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/builtin-bench.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index cae9a5f..afd1255 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -159,6 +159,7 @@ static void all_suite(struct bench_subsys *subsys)    /* 
FROM HERE */
                printf("# Running %s/%s benchmark...\n",
                       subsys->name,
                       suites[i].name);
+               fflush(stdout);
 
                argv[1] = suites[i].name;
                suites[i].fn(1, argv, NULL);
@@ -225,6 +226,7 @@ int cmd_bench(int argc, const char **argv, const char 
*prefix __maybe_unused)
                                printf("# Running %s/%s benchmark...\n",
                                       subsystems[i].name,
                                       subsystems[i].suites[j].name);
+                       fflush(stdout);
                        status = subsystems[i].suites[j].fn(argc - 1,
                                                            argv + 1, prefix);
                        goto end;
-- 
1.8.1.1.361.gec3ae6e

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to