This is helpful because some searches are an order of magnitude easier
than others.
| ... | ... |
@@ -199,7 +199,7 @@ static struct option longopts[] = {{"show-matches", required_argument, NULL, 'e'
|
| 199 | 199 |
{"prompt", required_argument, NULL, 'p'},
|
| 200 | 200 |
{"show-scores", no_argument, NULL, 's'},
|
| 201 | 201 |
{"version", no_argument, NULL, 'v'},
|
| 202 |
- {"benchmark", no_argument, NULL, 'b'},
|
|
| 202 |
+ {"benchmark", optional_argument, NULL, 'b'},
|
|
| 203 | 203 |
{"help", no_argument, NULL, 'h'},
|
| 204 | 204 |
{NULL, 0, NULL, 0}};
|
| 205 | 205 |
|
| ... | ... |
@@ -220,7 +220,14 @@ int main(int argc, char *argv[]) {
|
| 220 | 220 |
initial_query = optarg; |
| 221 | 221 |
break; |
| 222 | 222 |
case 'b': |
| 223 |
- benchmark = 1; |
|
| 223 |
+ if (optarg) {
|
|
| 224 |
+ if (sscanf(optarg, "%d", &benchmark) != 1) {
|
|
| 225 |
+ usage(argv[0]); |
|
| 226 |
+ exit(EXIT_FAILURE); |
|
| 227 |
+ } |
|
| 228 |
+ } else {
|
|
| 229 |
+ benchmark = 100; |
|
| 230 |
+ } |
|
| 224 | 231 |
break; |
| 225 | 232 |
case 't': |
| 226 | 233 |
tty_filename = optarg; |
| ... | ... |
@@ -263,7 +270,7 @@ int main(int argc, char *argv[]) {
|
| 263 | 270 |
fprintf(stderr, "Must specify -e/--show-matches with --benchmark\n"); |
| 264 | 271 |
exit(EXIT_FAILURE); |
| 265 | 272 |
} |
| 266 |
- for (int i = 0; i < 100; i++) |
|
| 273 |
+ for (int i = 0; i < benchmark; i++) |
|
| 267 | 274 |
choices_search(&choices, initial_query); |
| 268 | 275 |
} else if (initial_query) {
|
| 269 | 276 |
choices_search(&choices, initial_query); |