From: msweet Date: Wed, 29 May 2013 11:51:03 +0000 (+0000) Subject: Add option to specify a single operation to test with. X-Git-Tag: release-1.7rc1~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23ef1cac65a36f01e78a88f4d987e6350b441990;p=thirdparty%2Fcups.git Add option to specify a single operation to test with. Add CUPS-Get-Default to the list of standard ops to test. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10995 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/scheduler/testspeed.c b/scheduler/testspeed.c index 4aeaf26769..2be9302f53 100644 --- a/scheduler/testspeed.c +++ b/scheduler/testspeed.c @@ -1,5 +1,5 @@ /* - * "$Id: testspeed.c 7727 2008-07-14 18:02:21Z mike $" + * "$Id$" * * Scheduler speed test for CUPS. * @@ -39,7 +39,7 @@ static int do_test(const char *server, int port, http_encryption_t encryption, int requests, - int verbose); + const char *opstring, int verbose); static void usage(void) __attribute__((noreturn)); @@ -66,6 +66,7 @@ main(int argc, /* I - Number of command-line arguments */ end; /* End time */ double elapsed; /* Elapsed time */ int verbose; /* Verbosity */ + const char *opstring; /* Operation name */ /* @@ -78,6 +79,7 @@ main(int argc, /* I - Number of command-line arguments */ port = ippPort(); encryption = HTTP_ENCRYPT_IF_REQUESTED; verbose = 0; + opstring = NULL; for (i = 1; i < argc; i ++) if (argv[i][0] == '-') @@ -85,6 +87,10 @@ main(int argc, /* I - Number of command-line arguments */ for (ptr = argv[i] + 1; *ptr; ptr ++) switch (*ptr) { + case 'E' : /* Enable encryption */ + encryption = HTTP_ENCRYPT_REQUIRED; + break; + case 'c' : /* Number of children */ i ++; if (i >= argc) @@ -93,16 +99,20 @@ main(int argc, /* I - Number of command-line arguments */ children = atoi(argv[i]); break; - case 'r' : /* Number of requests */ + case 'o' : /* Operation */ i ++; if (i >= argc) usage(); - requests = atoi(argv[i]); + opstring = argv[i]; break; - case 'E' : /* Enable encryption */ - encryption = HTTP_ENCRYPT_REQUIRED; + case 'r' : /* Number of requests */ + i ++; + if (i >= argc) + usage(); + + requests = atoi(argv[i]); break; case 'v' : /* Verbose logging */ @@ -139,9 +149,10 @@ main(int argc, /* I - Number of command-line arguments */ start = time(NULL); if (children < 1) - return (do_test(server, port, encryption, requests, verbose)); + return (do_test(server, port, encryption, requests, opstring, verbose)); else if (children == 1) - good_children = do_test(server, port, encryption, requests, verbose) ? 0 : 1; + good_children = do_test(server, port, encryption, requests, opstring, + verbose) ? 0 : 1; else { char options[255], /* Command-line options for child */ @@ -174,7 +185,12 @@ main(int argc, /* I - Number of command-line arguments */ * Child goes here... */ - execlp(argv[0], argv[0], options, "0", reqstr, serverstr, (char *)NULL); + if (opstring) + execlp(argv[0], argv[0], options, "0", reqstr, "-o", opstring, + serverstr, (char *)NULL); + else + execlp(argv[0], argv[0], options, "0", reqstr, serverstr, (char *)NULL); + exit(errno); } else if (pid < 0) @@ -237,6 +253,7 @@ do_test(const char *server, /* I - Server to use */ int port, /* I - Port number to use */ http_encryption_t encryption, /* I - Encryption to use */ int requests, /* I - Number of requests to send */ + const char *opstring, /* I - Operation string */ int verbose) /* I - Verbose output? */ { int i; /* Looping var */ @@ -247,9 +264,10 @@ do_test(const char *server, /* I - Server to use */ double reqtime, /* Time for this request */ elapsed; /* Elapsed time */ int op; /* Current operation */ - static ipp_op_t ops[4] = /* Operations to test... */ + static ipp_op_t ops[5] = /* Operations to test... */ { IPP_PRINT_JOB, + CUPS_GET_DEFAULT, CUPS_GET_PRINTERS, CUPS_GET_CLASSES, IPP_GET_JOBS @@ -282,7 +300,11 @@ do_test(const char *server, /* I - Server to use */ * In addition, IPP_GET_JOBS needs a printer-uri attribute. */ - op = ops[i & 3]; + if (opstring) + op = ippOpValue(opstring); + else + op = ops[i % (sizeof(ops) / sizeof(ops[0]))]; + request = ippNewRequest(op); gettimeofday(&start, NULL); @@ -353,13 +375,13 @@ do_test(const char *server, /* I - Server to use */ static void usage(void) { - puts("Usage: testspeed [-c children] [-h] [-r requests] [-v] [-E] " - "hostname[:port]"); + puts("Usage: testspeed [-c children] [-h] [-o operation] [-r requests] [-v] " + "[-E] hostname[:port]"); exit(0); } /* - * End of "$Id: testspeed.c 7727 2008-07-14 18:02:21Z mike $". + * End of "$Id$". */