]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
perf bench: Add --repeat option
authorDavidlohr Bueso <davidlohr@hp.com>
Mon, 16 Jun 2014 18:14:19 +0000 (11:14 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 19 Jun 2014 19:13:15 +0000 (16:13 -0300)
There are a number of benchmarks that do single runs and as a result
does not really help users gain a general idea of how the workload
performs. So the user must either manually do multiple runs or just use
single bogus results.

This option will enable users to specify the amount of runs (arbitrarily
defaulted to 10, to use the existing benchmarks default) through the
'--repeat' option.  Add it to perf-bench instead of implementing it
always in each specific benchmark.

Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1402942467-10671-2-git-send-email-davidlohr@hp.com
[ Kept the existing default of 10, changing it to something else should
  be done on separate patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-bench.txt
tools/perf/bench/bench.h
tools/perf/builtin-bench.c

index 4464ad770d51257e392dfa801c64adcba72e76d7..f6480cbf309b40fee97e86112033c1a0cf04236a 100644 (file)
@@ -16,6 +16,10 @@ This 'perf bench' command is a general framework for benchmark suites.
 
 COMMON OPTIONS
 --------------
+-r::
+--repeat=::
+Specify amount of times to repeat the run (default 10).
+
 -f::
 --format=::
 Specify format style.
index eba46709b279d42244f1ed85265c390e2778b500..3c4dd44d45cb7b668bd22822b6f105c1de9eaf86 100644 (file)
@@ -43,5 +43,6 @@ extern int bench_futex_requeue(int argc, const char **argv, const char *prefix);
 #define BENCH_FORMAT_UNKNOWN           -1
 
 extern int bench_format;
+extern unsigned int bench_repeat;
 
 #endif
index 1e6e77710545afc472eae5c0f5e5a63f5ec432d1..b9a56fa8333065271a9242e98cf052d9c8100b87 100644 (file)
@@ -104,9 +104,11 @@ static const char *bench_format_str;
 
 /* Output/formatting style, exported to benchmark modules: */
 int bench_format = BENCH_FORMAT_DEFAULT;
+unsigned int bench_repeat = 10; /* default number of times to repeat the run */
 
 static const struct option bench_options[] = {
        OPT_STRING('f', "format", &bench_format_str, "default", "Specify format style"),
+       OPT_UINTEGER('r', "repeat",  &bench_repeat,   "Specify amount of times to repeat the run"),
        OPT_END()
 };
 
@@ -226,6 +228,11 @@ int cmd_bench(int argc, const char **argv, const char *prefix __maybe_unused)
                goto end;
        }
 
+       if (bench_repeat == 0) {
+               printf("Invalid repeat option: Must specify a positive value\n");
+               goto end;
+       }
+
        if (argc < 1) {
                print_usage();
                goto end;