perf bench: Flush stdout before starting bench suite
Namhyung Kim
maintainerPATCH 1/1 perf bench: Flush stdout before starting bench suite
From: Namhyung Kim <[email protected]>
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.
--- tools/perf/builtin-bench.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/builtin-bench.c +2 -0
@@ -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;
Signature · 1 line
1.7.11.7
At Tue, 8 Jan 2013 18:39:26 +0900,
Quoted 19 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
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 runTotal time: 0.100 [sec]$ perf bench sched messaging > result.txt $ wc -l result.txt 391
Quoted 6 lines
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.
Thanks a lot, I couldn't notice this problem.
Quoted 31 lines
Cc Hitoshi Mitake <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-bench.c | 2 ++ 1 file changed, 2 insertions(+)tools/perf/builtin-bench.c +2
-0@@ -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;Signature · 1 line
1.7.11.7
Commit-ID: 9b494ea2f5638184bc203a30062b32b9a9a05d9e Gitweb: http://git.kernel.org/tip/9b494ea2f5638184bc203a30062b32b9a9a05d9e Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 8 Jan 2013 18:39:26 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 24 Jan 2013 16:40:19 -0300
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.
--- tools/perf/builtin-bench.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/builtin-bench.c +2 -0
@@ -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;