This patch series adds new option "--format" to
bench subcommand of perf.
Users of perf bench will be able to specify
style formatting with this option in common way.
Hitoshi Mitake (4):
perf bench: Add stuffs to bench.h for unified output formatting
perf bench: Modify builtin-bench.c for processing common options
perf bench: Modified bench/bench-messaging.c to adopt unified output
formatting
perf bench: Modify builtin-pipe.c for processing common options
tools/perf/bench/bench.h | 9 ++++
tools/perf/bench/sched-messaging.c | 18 +++++---
tools/perf/bench/sched-pipe.c | 22 ++++++----
tools/perf/builtin-bench.c | 79 +++++++++++++++++++++++++++++------
4 files changed, 99 insertions(+), 29 deletions(-)
This patch adds some constants and extern declaration to bench.h.
These stuffs are used for unified output formatting
of 'perf bench'.
Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
---
tools/perf/bench/bench.h | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h
index 59adb27..42167ea 100644
--- a/tools/perf/bench/bench.h
+++ b/tools/perf/bench/bench.h
@@ -6,4 +6,13 @@ extern int bench_sched_messaging(int argc, const char **argv,
extern int bench_sched_pipe(int argc, const char **argv,
const char *prefix);
+#define BENCH_FORMAT_DEFAULT_STR "default"
+#define BENCH_FORMAT_DEFAULT 0
+#define BENCH_FORMAT_SIMPLE_STR "simple"
+#define BENCH_FORMAT_SIMPLE 1
+
+#define BENCH_FORMAT_UNKNOWN -1
+
+extern int bench_format;
+
#endif
--
1.5.6.5
This patch modifies builtin-bench.c for processing common options.
The first option added is "--format".
Users of perf bench will be able to specify output style by --format.
Example of use:
% ./perf bench sched messaging # with no style specify
(20 sender and receiver processes per group)
(10 groups == 400 processes run)
Total time:1.431 sec
% ./perf bench --format=simple sched messaging # specified simple
1.431
Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
---
tools/perf/builtin-bench.c | 79 ++++++++++++++++++++++++++++++++++++--------
1 files changed, 65 insertions(+), 14 deletions(-)
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index 31f4164..c7505ea 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -74,53 +74,104 @@ static void dump_suites(int subsys_index)
return;
}
+static char *bench_format_str;
+int bench_format = BENCH_FORMAT_DEFAULT;
+
+static const struct option bench_options[] = {
+ OPT_STRING('f', "format", &bench_format_str, "default",
+ "Specify format style"),
+ OPT_END()
+};
+
+static const char * const bench_usage[] = {
+ "perf bench [<common options>] <subsystem> <suite> [<options>]",
+ NULL
+};
+
+static void print_usage(void)
+{
+ int i;
+
+ printf("Usage: \n");
+ for (i = 0; bench_usage[i]; i++)
+ printf("\t%s\n", bench_usage[i]);
+ printf("\n");
+
+ printf("List of available subsystems...\n\n");
+
+ for (i = 0; subsystems[i].name; i++)
+ printf("\t%s: %s\n",
+ subsystems[i].name, subsystems[i].summary);
+ printf("\n");
+}
+
+static int bench_str2int(char *str)
+{
+ if (!str)
+ return BENCH_FORMAT_DEFAULT;
+
+ if (!strcmp(str, BENCH_FORMAT_DEFAULT_STR))
+ return BENCH_FORMAT_DEFAULT;
+ else if (!strcmp(str, BENCH_FORMAT_SIMPLE_STR))
+ return BENCH_FORMAT_SIMPLE;
+
+ return BENCH_FORMAT_UNKNOWN;
+}
+
int cmd_bench(int argc, const char **argv, const char *prefix __used)
{
int i, j, status = 0;
if (argc < 2) {
/* No subsystem specified. */
- printf("Usage: perf bench <subsystem> <suite> [<options>]\n\n");
- printf("List of available subsystems...\n\n");
+ print_usage();
+ goto end;
+ }
- for (i = 0; subsystems[i].name; i++)
- printf("\t%s: %s\n",
- subsystems[i].name, subsystems[i].summary);
- printf("\n");
+ argc = parse_options(argc, argv, bench_options, bench_usage,
+ PARSE_OPT_STOP_AT_NON_OPTION);
+
+ bench_format = bench_str2int(bench_format_str);
+ if (bench_format == BENCH_FORMAT_UNKNOWN) {
+ printf("Unknown format descriptor:%s\n", bench_format_str);
+ goto end;
+ }
+ if (argc < 1) {
+ print_usage();
goto end;
}
for (i = 0; subsystems[i].name; i++) {
- if (strcmp(subsystems[i].name, argv[1]))
+ if (strcmp(subsystems[i].name, argv[0]))
continue;
- if (argc < 3) {
+ if (argc < 2) {
/* No suite specified. */
dump_suites(i);
goto end;
}
for (j = 0; subsystems[i].suites[j].name; j++) {
- if (strcmp(subsystems[i].suites[j].name, argv[2]))
+ if (strcmp(subsystems[i].suites[j].name, argv[1]))
continue;
- status = subsystems[i].suites[j].fn(argc - 2,
- argv + 2, prefix);
+ status = subsystems[i].suites[j].fn(argc - 1,
+ argv + 1, prefix);
goto end;
}
- if (!strcmp(argv[2], "-h") || !strcmp(argv[2], "--help")) {
+ if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
dump_suites(i);
goto end;
}
- printf("Unknown suite:%s for %s\n", argv[2], argv[1]);
+ printf("Unknown suite:%s for %s\n", argv[1], argv[0]);
status = 1;
goto end;
}
- printf("Unknown subsystem:%s\n", argv[1]);
+ printf("Unknown subsystem:%s\n", argv[0]);
status = 1;
end:
--
1.5.6.5
This patch modifies bench/bench-messaging.c to adopt
unified output formatting: --format option.
Example of use:
% ./perf bench sched messaging # with no style specify
(20 sender and receiver processes per group)
(10 groups == 400 processes run)
Total time:1.431 sec
% ./perf bench --format=simple sched messaging # specified simple
1.431
Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
---
tools/perf/bench/sched-messaging.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c
index 36b62c5..2cc5edc 100644
--- a/tools/perf/bench/sched-messaging.c
+++ b/tools/perf/bench/sched-messaging.c
@@ -35,7 +35,6 @@ static int use_pipes = 0;
static unsigned int loops = 100;
static unsigned int thread_mode = 0;
static unsigned int num_groups = 10;
-static int simple = 0;
struct sender_context {
unsigned int num_fds;
@@ -261,9 +260,6 @@ static const struct option options[] = {
"Specify number of groups"),
OPT_INTEGER('l', "loop", &loops,
"Specify number of loops"),
- OPT_BOOLEAN('s', "simple-output", &simple,
- "Do simple output (this maybe useful for"
- "processing by scripts or graph tools like gnuplot)"),
OPT_END()
};
@@ -316,9 +312,8 @@ int bench_sched_messaging(int argc, const char **argv,
timersub(&stop, &start, &diff);
- if (simple)
- printf("%lu.%03lu\n", diff.tv_sec, diff.tv_usec/1000);
- else {
+ switch (bench_format) {
+ case BENCH_FORMAT_DEFAULT:
printf("(%d sender and receiver %s per group)\n",
num_fds, thread_mode ? "threads" : "processes");
printf("(%d groups == %d %s run)\n\n",
@@ -326,6 +321,15 @@ int bench_sched_messaging(int argc, const char **argv,
thread_mode ? "threads" : "processes");
printf("\tTotal time:%lu.%03lu sec\n",
diff.tv_sec, diff.tv_usec/1000);
+ break;
+ case BENCH_FORMAT_SIMPLE:
+ printf("%lu.%03lu\n", diff.tv_sec, diff.tv_usec/1000);
+ break;
+ default:
+ /* reaching here is something disaster */
+ fprintf(stderr, "Unknown format:%d\n", bench_format);
+ exit(1);
+ break;
}
return 0;
--
1.5.6.5
This patch modifies builtin-pipe.c for processing common options.
The first option added is "--format".
Users of perf bench will be able to specify output style by --format.
Example of use:
% ./perf bench sched pipe # with no style specify
(executing 1000000 pipe operations between two tasks)
Total time:5.855 sec
5.855061 usecs/op
170792 ops/sec
% ./perf bench --format=simple sched pipe # specified simple
5.988
Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
---
tools/perf/bench/sched-pipe.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index 6a29100..a9ac186 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -30,14 +30,10 @@
#define LOOPS_DEFAULT 1000000
static int loops = LOOPS_DEFAULT;
-static int simple = 0;
static const struct option options[] = {
OPT_INTEGER('l', "loop", &loops,
"Specify number of loops"),
- OPT_BOOLEAN('s', "simple-output", &simple,
- "Do simple output (this maybe useful for"
- "processing by scripts or graph tools like gnuplot)"),
OPT_END()
};
@@ -94,10 +90,8 @@ int bench_sched_pipe(int argc, const char **argv,
return 0;
}
- if (simple)
- printf("%lu.%03lu\n",
- diff.tv_sec, diff.tv_usec / 1000);
- else {
+ switch (bench_format) {
+ case BENCH_FORMAT_DEFAULT:
printf("(executing %d pipe operations between two tasks)\n\n",
loops);
@@ -111,6 +105,18 @@ int bench_sched_pipe(int argc, const char **argv,
printf("\t\t%d ops/sec\n",
(int)((double)loops /
((double)result_usec / (double)1000000)));
+ break;
+
+ case BENCH_FORMAT_SIMPLE:
+ printf("%lu.%03lu\n",
+ diff.tv_sec, diff.tv_usec / 1000);
+ break;
+
+ default:
+ /* reaching here is something disaster */
+ fprintf(stderr, "Unknown format:%d\n", bench_format);
+ exit(1);
+ break;
}
return 0;
--
1.5.6.5
* Hitoshi Mitake <[email protected]> wrote:
> This patch series adds new option "--format" to
> bench subcommand of perf.
>
> Users of perf bench will be able to specify
> style formatting with this option in common way.
>
> Hitoshi Mitake (4):
> perf bench: Add stuffs to bench.h for unified output formatting
> perf bench: Modify builtin-bench.c for processing common options
> perf bench: Modified bench/bench-messaging.c to adopt unified output
> formatting
> perf bench: Modify builtin-pipe.c for processing common options
>
> tools/perf/bench/bench.h | 9 ++++
> tools/perf/bench/sched-messaging.c | 18 +++++---
> tools/perf/bench/sched-pipe.c | 22 ++++++----
> tools/perf/builtin-bench.c | 79 +++++++++++++++++++++++++++++------
> 4 files changed, 99 insertions(+), 29 deletions(-)
Very nice, applied to tip:perf/bench, thanks!
A (very) small detail about initializers in bench.h:
- No need to break the line for function prototypes, they are more
readable in a single line. (even if checkpatch complains about it)
- We try to align definitions / structure fields vertically, to make it
all a bit more readable.
Something like the (untested) cleanup patch below. (Just put it into
your next batch of commits.)
Thanks,
Ingo
---
tools/perf/bench/bench.h | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
Index: tip/tools/perf/bench/bench.h
===================================================================
--- tip.orig/tools/perf/bench/bench.h
+++ tip/tools/perf/bench/bench.h
@@ -1,17 +1,15 @@
#ifndef BENCH_H
#define BENCH_H
-extern int bench_sched_messaging(int argc, const char **argv,
- const char *prefix);
-extern int bench_sched_pipe(int argc, const char **argv,
- const char *prefix);
+extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
+extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
-#define BENCH_FORMAT_DEFAULT_STR "default"
-#define BENCH_FORMAT_DEFAULT 0
-#define BENCH_FORMAT_SIMPLE_STR "simple"
-#define BENCH_FORMAT_SIMPLE 1
+#define BENCH_FORMAT_DEFAULT_STR "default"
+#define BENCH_FORMAT_DEFAULT 0
+#define BENCH_FORMAT_SIMPLE_STR "simple"
+#define BENCH_FORMAT_SIMPLE 1
-#define BENCH_FORMAT_UNKNOWN -1
+#define BENCH_FORMAT_UNKNOWN -1
extern int bench_format;
Commit-ID: 242aa14a67f4e19453fc8a51cffc5ac5ee5bcbd1
Gitweb: http://git.kernel.org/tip/242aa14a67f4e19453fc8a51cffc5ac5ee5bcbd1
Author: Hitoshi Mitake <[email protected]>
AuthorDate: Tue, 10 Nov 2009 08:19:59 +0900
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 10 Nov 2009 04:53:48 +0100
perf bench: Add format constants to bench.h for unified output formatting
This patch adds some constants and extern declaration to
bench.h. These are used for unified output formatting
of 'perf bench'.
Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/bench/bench.h | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h
index 59adb27..42167ea 100644
--- a/tools/perf/bench/bench.h
+++ b/tools/perf/bench/bench.h
@@ -6,4 +6,13 @@ extern int bench_sched_messaging(int argc, const char **argv,
extern int bench_sched_pipe(int argc, const char **argv,
const char *prefix);
+#define BENCH_FORMAT_DEFAULT_STR "default"
+#define BENCH_FORMAT_DEFAULT 0
+#define BENCH_FORMAT_SIMPLE_STR "simple"
+#define BENCH_FORMAT_SIMPLE 1
+
+#define BENCH_FORMAT_UNKNOWN -1
+
+extern int bench_format;
+
#endif
Commit-ID: 386d7e9e542c2115d5d300747e57f503458a1617
Gitweb: http://git.kernel.org/tip/386d7e9e542c2115d5d300747e57f503458a1617
Author: Hitoshi Mitake <[email protected]>
AuthorDate: Tue, 10 Nov 2009 08:20:00 +0900
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 10 Nov 2009 04:53:48 +0100
perf bench: Modify builtin-bench.c for processing common options
This patch modifies builtin-bench.c for processing common
options. The first option added is "--format".
Users of perf bench will be able to specify output style by
--format.
Usage example:
% ./perf bench sched messaging # with no style specify
(20 sender and receiver processes per group)
(10 groups == 400 processes run)
Total time:1.431 sec
% ./perf bench --format=simple sched messaging # specified
simple 1.431
Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/builtin-bench.c | 79 ++++++++++++++++++++++++++++++++++++--------
1 files changed, 65 insertions(+), 14 deletions(-)
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
index 31f4164..c7505ea 100644
--- a/tools/perf/builtin-bench.c
+++ b/tools/perf/builtin-bench.c
@@ -74,53 +74,104 @@ static void dump_suites(int subsys_index)
return;
}
+static char *bench_format_str;
+int bench_format = BENCH_FORMAT_DEFAULT;
+
+static const struct option bench_options[] = {
+ OPT_STRING('f', "format", &bench_format_str, "default",
+ "Specify format style"),
+ OPT_END()
+};
+
+static const char * const bench_usage[] = {
+ "perf bench [<common options>] <subsystem> <suite> [<options>]",
+ NULL
+};
+
+static void print_usage(void)
+{
+ int i;
+
+ printf("Usage: \n");
+ for (i = 0; bench_usage[i]; i++)
+ printf("\t%s\n", bench_usage[i]);
+ printf("\n");
+
+ printf("List of available subsystems...\n\n");
+
+ for (i = 0; subsystems[i].name; i++)
+ printf("\t%s: %s\n",
+ subsystems[i].name, subsystems[i].summary);
+ printf("\n");
+}
+
+static int bench_str2int(char *str)
+{
+ if (!str)
+ return BENCH_FORMAT_DEFAULT;
+
+ if (!strcmp(str, BENCH_FORMAT_DEFAULT_STR))
+ return BENCH_FORMAT_DEFAULT;
+ else if (!strcmp(str, BENCH_FORMAT_SIMPLE_STR))
+ return BENCH_FORMAT_SIMPLE;
+
+ return BENCH_FORMAT_UNKNOWN;
+}
+
int cmd_bench(int argc, const char **argv, const char *prefix __used)
{
int i, j, status = 0;
if (argc < 2) {
/* No subsystem specified. */
- printf("Usage: perf bench <subsystem> <suite> [<options>]\n\n");
- printf("List of available subsystems...\n\n");
+ print_usage();
+ goto end;
+ }
- for (i = 0; subsystems[i].name; i++)
- printf("\t%s: %s\n",
- subsystems[i].name, subsystems[i].summary);
- printf("\n");
+ argc = parse_options(argc, argv, bench_options, bench_usage,
+ PARSE_OPT_STOP_AT_NON_OPTION);
+
+ bench_format = bench_str2int(bench_format_str);
+ if (bench_format == BENCH_FORMAT_UNKNOWN) {
+ printf("Unknown format descriptor:%s\n", bench_format_str);
+ goto end;
+ }
+ if (argc < 1) {
+ print_usage();
goto end;
}
for (i = 0; subsystems[i].name; i++) {
- if (strcmp(subsystems[i].name, argv[1]))
+ if (strcmp(subsystems[i].name, argv[0]))
continue;
- if (argc < 3) {
+ if (argc < 2) {
/* No suite specified. */
dump_suites(i);
goto end;
}
for (j = 0; subsystems[i].suites[j].name; j++) {
- if (strcmp(subsystems[i].suites[j].name, argv[2]))
+ if (strcmp(subsystems[i].suites[j].name, argv[1]))
continue;
- status = subsystems[i].suites[j].fn(argc - 2,
- argv + 2, prefix);
+ status = subsystems[i].suites[j].fn(argc - 1,
+ argv + 1, prefix);
goto end;
}
- if (!strcmp(argv[2], "-h") || !strcmp(argv[2], "--help")) {
+ if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
dump_suites(i);
goto end;
}
- printf("Unknown suite:%s for %s\n", argv[2], argv[1]);
+ printf("Unknown suite:%s for %s\n", argv[1], argv[0]);
status = 1;
goto end;
}
- printf("Unknown subsystem:%s\n", argv[1]);
+ printf("Unknown subsystem:%s\n", argv[0]);
status = 1;
end:
Commit-ID: cced06c62a9db6bd6d77e3f0a57dbe47a26d881e
Gitweb: http://git.kernel.org/tip/cced06c62a9db6bd6d77e3f0a57dbe47a26d881e
Author: Hitoshi Mitake <[email protected]>
AuthorDate: Tue, 10 Nov 2009 08:20:01 +0900
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 10 Nov 2009 04:53:49 +0100
perf bench: Modify bench/bench-messaging.c to adopt unified output formatting
This patch modifies bench/bench-messaging.c to adopt
unified output formatting: --format option.
Usage example:
% ./perf bench sched messaging # with no style
specify (20 sender and receiver processes per group)
(10 groups == 400 processes run)
Total time:1.431 sec
% ./perf bench --format=simple sched messaging # specified
simple 1.431
Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/bench/sched-messaging.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c
index 36b62c5..2cc5edc 100644
--- a/tools/perf/bench/sched-messaging.c
+++ b/tools/perf/bench/sched-messaging.c
@@ -35,7 +35,6 @@ static int use_pipes = 0;
static unsigned int loops = 100;
static unsigned int thread_mode = 0;
static unsigned int num_groups = 10;
-static int simple = 0;
struct sender_context {
unsigned int num_fds;
@@ -261,9 +260,6 @@ static const struct option options[] = {
"Specify number of groups"),
OPT_INTEGER('l', "loop", &loops,
"Specify number of loops"),
- OPT_BOOLEAN('s', "simple-output", &simple,
- "Do simple output (this maybe useful for"
- "processing by scripts or graph tools like gnuplot)"),
OPT_END()
};
@@ -316,9 +312,8 @@ int bench_sched_messaging(int argc, const char **argv,
timersub(&stop, &start, &diff);
- if (simple)
- printf("%lu.%03lu\n", diff.tv_sec, diff.tv_usec/1000);
- else {
+ switch (bench_format) {
+ case BENCH_FORMAT_DEFAULT:
printf("(%d sender and receiver %s per group)\n",
num_fds, thread_mode ? "threads" : "processes");
printf("(%d groups == %d %s run)\n\n",
@@ -326,6 +321,15 @@ int bench_sched_messaging(int argc, const char **argv,
thread_mode ? "threads" : "processes");
printf("\tTotal time:%lu.%03lu sec\n",
diff.tv_sec, diff.tv_usec/1000);
+ break;
+ case BENCH_FORMAT_SIMPLE:
+ printf("%lu.%03lu\n", diff.tv_sec, diff.tv_usec/1000);
+ break;
+ default:
+ /* reaching here is something disaster */
+ fprintf(stderr, "Unknown format:%d\n", bench_format);
+ exit(1);
+ break;
}
return 0;
Commit-ID: 158ba827f6deef4102c5247ed4b6a587f0bd6a07
Gitweb: http://git.kernel.org/tip/158ba827f6deef4102c5247ed4b6a587f0bd6a07
Author: Hitoshi Mitake <[email protected]>
AuthorDate: Tue, 10 Nov 2009 08:20:02 +0900
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 10 Nov 2009 04:53:49 +0100
perf bench: Modify builtin-pipe.c for processing common options
This patch modifies builtin-pipe.c for processing common
options. The first option added is "--format".
Users of perf bench will be able to specify output style by
--format.
Usage example:
% ./perf bench sched pipe # with no style specify
(executing 1000000 pipe operations between two tasks)
Total time:5.855 sec
5.855061 usecs/op
170792 ops/sec
% ./perf bench --format=simple sched pipe # specified simple
5.988
Signed-off-by: Hitoshi Mitake <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
---
tools/perf/bench/sched-pipe.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index 6a29100..a9ac186 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -30,14 +30,10 @@
#define LOOPS_DEFAULT 1000000
static int loops = LOOPS_DEFAULT;
-static int simple = 0;
static const struct option options[] = {
OPT_INTEGER('l', "loop", &loops,
"Specify number of loops"),
- OPT_BOOLEAN('s', "simple-output", &simple,
- "Do simple output (this maybe useful for"
- "processing by scripts or graph tools like gnuplot)"),
OPT_END()
};
@@ -94,10 +90,8 @@ int bench_sched_pipe(int argc, const char **argv,
return 0;
}
- if (simple)
- printf("%lu.%03lu\n",
- diff.tv_sec, diff.tv_usec / 1000);
- else {
+ switch (bench_format) {
+ case BENCH_FORMAT_DEFAULT:
printf("(executing %d pipe operations between two tasks)\n\n",
loops);
@@ -111,6 +105,18 @@ int bench_sched_pipe(int argc, const char **argv,
printf("\t\t%d ops/sec\n",
(int)((double)loops /
((double)result_usec / (double)1000000)));
+ break;
+
+ case BENCH_FORMAT_SIMPLE:
+ printf("%lu.%03lu\n",
+ diff.tv_sec, diff.tv_usec / 1000);
+ break;
+
+ default:
+ /* reaching here is something disaster */
+ fprintf(stderr, "Unknown format:%d\n", bench_format);
+ exit(1);
+ break;
}
return 0;
From: Ingo Molnar <[email protected]>
Subject: Re: [PATCH v2 0/4] perf bench: Common option for specifying style formatting
Date: Tue, 10 Nov 2009 04:58:12 +0100
> > bench subcommand of perf.
> >
> > Users of perf bench will be able to specify
> > style formatting with this option in common way.
> >
> > Hitoshi Mitake (4):
> > perf bench: Add stuffs to bench.h for unified output formatting
> > perf bench: Modify builtin-bench.c for processing common options
> > perf bench: Modified bench/bench-messaging.c to adopt unified output
> > formatting
> > perf bench: Modify builtin-pipe.c for processing common options
> >
> > tools/perf/bench/bench.h | 9 ++++
> > tools/perf/bench/sched-messaging.c | 18 +++++---
> > tools/perf/bench/sched-pipe.c | 22 ++++++----
> > tools/perf/builtin-bench.c | 79 +++++++++++++++++++++++++++++------
> > 4 files changed, 99 insertions(+), 29 deletions(-)
>
> Very nice, applied to tip:perf/bench, thanks!
>
> A (very) small detail about initializers in bench.h:
>
> - No need to break the line for function prototypes, they are more
> readable in a single line. (even if checkpatch complains about it)
>
> - We try to align definitions / structure fields vertically, to make it
> all a bit more readable.
>
> Something like the (untested) cleanup patch below. (Just put it into
> your next batch of commits.)
>
> Thanks,
>
> Ingo
>
> ---
> tools/perf/bench/bench.h | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> Index: tip/tools/perf/bench/bench.h
> ===================================================================
> --- tip.orig/tools/perf/bench/bench.h
> +++ tip/tools/perf/bench/bench.h
> @@ -1,17 +1,15 @@
> #ifndef BENCH_H
> #define BENCH_H
>
> -extern int bench_sched_messaging(int argc, const char **argv,
> - const char *prefix);
> -extern int bench_sched_pipe(int argc, const char **argv,
> - const char *prefix);
> +extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
> +extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
>
> -#define BENCH_FORMAT_DEFAULT_STR "default"
> -#define BENCH_FORMAT_DEFAULT 0
> -#define BENCH_FORMAT_SIMPLE_STR "simple"
> -#define BENCH_FORMAT_SIMPLE 1
> +#define BENCH_FORMAT_DEFAULT_STR "default"
> +#define BENCH_FORMAT_DEFAULT 0
> +#define BENCH_FORMAT_SIMPLE_STR "simple"
> +#define BENCH_FORMAT_SIMPLE 1
>
> -#define BENCH_FORMAT_UNKNOWN -1
> +#define BENCH_FORMAT_UNKNOWN -1
>
> extern int bench_format;
>
>
Thanks for your merge!
I tested your cleaning patch, and this has no problem.
So I'll queue this with next patch series post.
And I have a question.
In tools/perf/command-list.txt, there is the word "mainporcelain".
What does this mean?
Of course I searched this word on my dictionary, but cannot got an answer.
I'm preparing the initial document for perf-bench.
Can I add perf-bench with mainporcelain to command-list.txt?
* Hitoshi Mitake <[email protected]> wrote:
> And I have a question.
> In tools/perf/command-list.txt, there is the word "mainporcelain".
> What does this mean?
tools/perf/ inherited the command-list.txt code from the Git project:
git://git.kernel.org/pub/scm/git/git.git
in Git talk, 'porcelain' is the pretty stuff humans use. 'plumbing' is
the lowlevel stuff humans dont get to see.
'mainporcelain' are the major commands you get listed when you type
'perf' (or 'git').
( i've Cc:-ed the Git list as i never saw any real formal definition for
this anywhere, maybe i got this wrong :-)
> Of course I searched this word on my dictionary, but cannot got an answer.
> I'm preparing the initial document for perf-bench.
> Can I add perf-bench with mainporcelain to command-list.txt?
yeah, i'd suggest to do that - that will make 'perf bench' show up in
'perf' output.
Ingo
From: Ingo Molnar <[email protected]>
Subject: Re: [PATCH v2 0/4] perf bench: Common option for specifying style formatting
Date: Tue, 10 Nov 2009 09:01:35 +0100
>
> * Hitoshi Mitake <[email protected]> wrote:
>
> > And I have a question.
> > In tools/perf/command-list.txt, there is the word "mainporcelain".
> > What does this mean?
>
> tools/perf/ inherited the command-list.txt code from the Git project:
>
> git://git.kernel.org/pub/scm/git/git.git
>
> in Git talk, 'porcelain' is the pretty stuff humans use. 'plumbing' is
> the lowlevel stuff humans dont get to see.
>
> 'mainporcelain' are the major commands you get listed when you type
> 'perf' (or 'git').
Thanks, I got it!
>
> ( i've Cc:-ed the Git list as i never saw any real formal definition for
> this anywhere, maybe i got this wrong :-)
>
> > Of course I searched this word on my dictionary, but cannot got an answer.
> > I'm preparing the initial document for perf-bench.
> > Can I add perf-bench with mainporcelain to command-list.txt?
>
> yeah, i'd suggest to do that - that will make 'perf bench' show up in
> 'perf' output.
I'll describe perf bench as mainporcelain command, thanks.