]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/testspeed.c
Import CUPS v1.7.1
[thirdparty/cups.git] / scheduler / testspeed.c
index c9fe4ed68d193ee39bd7121aaaad49844b62f9a9..3e95f4a6646d7b3b5f182532792b9c1c77e3b34b 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: testspeed.c 7688 2008-06-24 04:34:52Z mike $"
+ * "$Id: testspeed.c 10995 2013-05-29 11:51:03Z msweet $"
  *
- *   Scheduler speed test for the Common UNIX Printing System (CUPS).
+ *   Scheduler speed test for CUPS.
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2010 by Apple Inc.
  *   Copyright 1997-2005 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
  * Include necessary headers...
  */
 
-#include <cups/string.h>
+#include <cups/string-private.h>
 #include <cups/cups.h>
 #include <cups/language.h>
-#include <cups/debug.h>
+#include <cups/debug-private.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/wait.h>
-#include <errno.h>
 
 
 /*
@@ -40,8 +39,8 @@
 
 static int     do_test(const char *server, int port,
                        http_encryption_t encryption, int requests,
-                       int verbose);
-static void    usage(void);
+                       const char *opstring, int verbose);
+static void    usage(void) __attribute__((noreturn));
 
 
 /*
@@ -67,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 */
 
 
  /*
@@ -79,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] == '-')
@@ -86,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)
@@ -94,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 */
@@ -140,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 */
@@ -175,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)
@@ -238,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 */
@@ -248,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
@@ -283,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);
@@ -354,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 7688 2008-06-24 04:34:52Z mike $".
+ * End of "$Id: testspeed.c 10995 2013-05-29 11:51:03Z msweet $".
  */