diff --git a/doc/src/sgml/ref/pgtesttiming.sgml b/doc/src/sgml/ref/pgtesttiming.sgml index bbb511ae94a..285f27f7c31 100644 --- a/doc/src/sgml/ref/pgtesttiming.sgml +++ b/doc/src/sgml/ref/pgtesttiming.sgml @@ -62,19 +62,6 @@ PostgreSQL documentation - - - - - - Specifies the test duration, in seconds. Longer durations - give slightly better accuracy, and are more likely to discover - problems with the system clock moving backwards. The default - test duration is 3 seconds. - - - - @@ -90,6 +77,19 @@ PostgreSQL documentation + + + + + + Specifies the test duration, in seconds. Longer durations + give slightly better accuracy, and are more likely to discover + problems with the system clock moving backwards. The default + test duration is 3 seconds. + + + + diff --git a/src/bin/pg_test_timing/pg_test_timing.c b/src/bin/pg_test_timing/pg_test_timing.c index fcfd0456b55..d63018f270f 100644 --- a/src/bin/pg_test_timing/pg_test_timing.c +++ b/src/bin/pg_test_timing/pg_test_timing.c @@ -62,8 +62,8 @@ static void handle_args(int argc, char *argv[]) { static struct option long_options[] = { - {"duration", required_argument, NULL, 'd'}, {"cutoff", required_argument, NULL, 'c'}, + {"duration", required_argument, NULL, 'd'}, {NULL, 0, NULL, 0} }; @@ -76,7 +76,7 @@ handle_args(int argc, char *argv[]) { if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0) { - printf(_("Usage: %s [-d DURATION] [-c CUTOFF]\n"), progname); + printf(_("Usage: %s [-c CUTOFF] [-d DURATION]\n"), progname); exit(0); } if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) @@ -86,11 +86,31 @@ handle_args(int argc, char *argv[]) } } - while ((option = getopt_long(argc, argv, "d:c:", + while ((option = getopt_long(argc, argv, "c:d:", long_options, &optindex)) != -1) { switch (option) { + case 'c': + errno = 0; + max_rprct = strtod(optarg, &endptr); + + if (endptr == optarg || *endptr != '\0' || errno != 0) + { + fprintf(stderr, _("%s: invalid argument for option %s\n"), + progname, "--cutoff"); + fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); + exit(1); + } + + if (max_rprct < 0 || max_rprct > 100) + { + fprintf(stderr, _("%s: %s must be in range %u..%u\n"), + progname, "--cutoff", 0, 100); + exit(1); + } + break; + case 'd': errno = 0; optval = strtoul(optarg, &endptr, 10); @@ -113,26 +133,6 @@ handle_args(int argc, char *argv[]) } break; - case 'c': - errno = 0; - max_rprct = strtod(optarg, &endptr); - - if (endptr == optarg || *endptr != '\0' || errno != 0) - { - fprintf(stderr, _("%s: invalid argument for option %s\n"), - progname, "--cutoff"); - fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); - exit(1); - } - - if (max_rprct < 0 || max_rprct > 100) - { - fprintf(stderr, _("%s: %s must be in range %u..%u\n"), - progname, "--cutoff", 0, 100); - exit(1); - } - break; - default: fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);