Commit 9b494ea2f5638184bc203a30062b32b9a9a05d9e

Authored by Namhyung Kim
Committed by Arnaldo Carvalho de Melo
1 parent eec185ab60

perf bench: Flush stdout before starting bench suite

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 <namhyung@kernel.org>
Acked-by: Hitoshi Mitake <h.mitake@gmail.com>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1357637966-8216-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Showing 1 changed file with 2 additions and 0 deletions Side-by-side Diff

tools/perf/builtin-bench.c
... ... @@ -159,6 +159,7 @@
159 159 printf("# Running %s/%s benchmark...\n",
160 160 subsys->name,
161 161 suites[i].name);
  162 + fflush(stdout);
162 163  
163 164 argv[1] = suites[i].name;
164 165 suites[i].fn(1, argv, NULL);
... ... @@ -225,6 +226,7 @@
225 226 printf("# Running %s/%s benchmark...\n",
226 227 subsystems[i].name,
227 228 subsystems[i].suites[j].name);
  229 + fflush(stdout);
228 230 status = subsystems[i].suites[j].fn(argc - 1,
229 231 argv + 1, prefix);
230 232 goto end;