diff options
author | Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> | 2009-11-09 18:20:00 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-09 22:53:48 -0500 |
commit | 386d7e9e542c2115d5d300747e57f503458a1617 (patch) | |
tree | 0cacfa2528b0f2ebbea2dddc69bd6cbec2250c13 | |
parent | 242aa14a67f4e19453fc8a51cffc5ac5ee5bcbd1 (diff) |
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 <mitake@dcl.info.waseda.ac.jp>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1257808802-9420-3-git-send-email-mitake@dcl.info.waseda.ac.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | 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 31f41643b0cd..c7505eaff84b 100644 --- a/tools/perf/builtin-bench.c +++ b/tools/perf/builtin-bench.c | |||
@@ -74,53 +74,104 @@ static void dump_suites(int subsys_index) | |||
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | 76 | ||
77 | static char *bench_format_str; | ||
78 | int bench_format = BENCH_FORMAT_DEFAULT; | ||
79 | |||
80 | static const struct option bench_options[] = { | ||
81 | OPT_STRING('f', "format", &bench_format_str, "default", | ||
82 | "Specify format style"), | ||
83 | OPT_END() | ||
84 | }; | ||
85 | |||
86 | static const char * const bench_usage[] = { | ||
87 | "perf bench [<common options>] <subsystem> <suite> [<options>]", | ||
88 | NULL | ||
89 | }; | ||
90 | |||
91 | static void print_usage(void) | ||
92 | { | ||
93 | int i; | ||
94 | |||
95 | printf("Usage: \n"); | ||
96 | for (i = 0; bench_usage[i]; i++) | ||
97 | printf("\t%s\n", bench_usage[i]); | ||
98 | printf("\n"); | ||
99 | |||
100 | printf("List of available subsystems...\n\n"); | ||
101 | |||
102 | for (i = 0; subsystems[i].name; i++) | ||
103 | printf("\t%s: %s\n", | ||
104 | subsystems[i].name, subsystems[i].summary); | ||
105 | printf("\n"); | ||
106 | } | ||
107 | |||
108 | static int bench_str2int(char *str) | ||
109 | { | ||
110 | if (!str) | ||
111 | return BENCH_FORMAT_DEFAULT; | ||
112 | |||
113 | if (!strcmp(str, BENCH_FORMAT_DEFAULT_STR)) | ||
114 | return BENCH_FORMAT_DEFAULT; | ||
115 | else if (!strcmp(str, BENCH_FORMAT_SIMPLE_STR)) | ||
116 | return BENCH_FORMAT_SIMPLE; | ||
117 | |||
118 | return BENCH_FORMAT_UNKNOWN; | ||
119 | } | ||
120 | |||
77 | int cmd_bench(int argc, const char **argv, const char *prefix __used) | 121 | int cmd_bench(int argc, const char **argv, const char *prefix __used) |
78 | { | 122 | { |
79 | int i, j, status = 0; | 123 | int i, j, status = 0; |
80 | 124 | ||
81 | if (argc < 2) { | 125 | if (argc < 2) { |
82 | /* No subsystem specified. */ | 126 | /* No subsystem specified. */ |
83 | printf("Usage: perf bench <subsystem> <suite> [<options>]\n\n"); | 127 | print_usage(); |
84 | printf("List of available subsystems...\n\n"); | 128 | goto end; |
129 | } | ||
85 | 130 | ||
86 | for (i = 0; subsystems[i].name; i++) | 131 | argc = parse_options(argc, argv, bench_options, bench_usage, |
87 | printf("\t%s: %s\n", | 132 | PARSE_OPT_STOP_AT_NON_OPTION); |
88 | subsystems[i].name, subsystems[i].summary); | 133 | |
89 | printf("\n"); | 134 | bench_format = bench_str2int(bench_format_str); |
135 | if (bench_format == BENCH_FORMAT_UNKNOWN) { | ||
136 | printf("Unknown format descriptor:%s\n", bench_format_str); | ||
137 | goto end; | ||
138 | } | ||
90 | 139 | ||
140 | if (argc < 1) { | ||
141 | print_usage(); | ||
91 | goto end; | 142 | goto end; |
92 | } | 143 | } |
93 | 144 | ||
94 | for (i = 0; subsystems[i].name; i++) { | 145 | for (i = 0; subsystems[i].name; i++) { |
95 | if (strcmp(subsystems[i].name, argv[1])) | 146 | if (strcmp(subsystems[i].name, argv[0])) |
96 | continue; | 147 | continue; |
97 | 148 | ||
98 | if (argc < 3) { | 149 | if (argc < 2) { |
99 | /* No suite specified. */ | 150 | /* No suite specified. */ |
100 | dump_suites(i); | 151 | dump_suites(i); |
101 | goto end; | 152 | goto end; |
102 | } | 153 | } |
103 | 154 | ||
104 | for (j = 0; subsystems[i].suites[j].name; j++) { | 155 | for (j = 0; subsystems[i].suites[j].name; j++) { |
105 | if (strcmp(subsystems[i].suites[j].name, argv[2])) | 156 | if (strcmp(subsystems[i].suites[j].name, argv[1])) |
106 | continue; | 157 | continue; |
107 | 158 | ||
108 | status = subsystems[i].suites[j].fn(argc - 2, | 159 | status = subsystems[i].suites[j].fn(argc - 1, |
109 | argv + 2, prefix); | 160 | argv + 1, prefix); |
110 | goto end; | 161 | goto end; |
111 | } | 162 | } |
112 | 163 | ||
113 | if (!strcmp(argv[2], "-h") || !strcmp(argv[2], "--help")) { | 164 | if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { |
114 | dump_suites(i); | 165 | dump_suites(i); |
115 | goto end; | 166 | goto end; |
116 | } | 167 | } |
117 | 168 | ||
118 | printf("Unknown suite:%s for %s\n", argv[2], argv[1]); | 169 | printf("Unknown suite:%s for %s\n", argv[1], argv[0]); |
119 | status = 1; | 170 | status = 1; |
120 | goto end; | 171 | goto end; |
121 | } | 172 | } |
122 | 173 | ||
123 | printf("Unknown subsystem:%s\n", argv[1]); | 174 | printf("Unknown subsystem:%s\n", argv[0]); |
124 | status = 1; | 175 | status = 1; |
125 | 176 | ||
126 | end: | 177 | end: |