]>
git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/testspeed.c
2 * "$Id: testspeed.c,v 1.4 2002/01/02 17:59:18 mike Exp $"
4 * Scheduler speed test for the Common UNIX Printing System (CUPS).
6 * Copyright 1997-2002 by Easy Software Products.
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636-3111 USA
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
29 * Include necessary headers...
36 #include <cups/cups.h>
37 #include <cups/language.h>
38 #include <cups/debug.h>
42 * 'main()' - Send multiple IPP requests and report on the average response
47 main(int argc
, /* I - Number of command-line arguments */
48 char *argv
[]) /* I - Command-line arguments */
50 int i
; /* Looping var */
51 http_t
*http
; /* Connection to server */
52 ipp_t
*request
, /* IPP Request */
53 *response
; /* IPP Response */
54 cups_lang_t
*language
; /* Default language */
55 struct timeval start
, /* Start time */
57 double elapsed
; /* Elapsed time */
61 http
= httpConnect(argv
[1], ippPort());
63 http
= httpConnect("localhost", ippPort());
67 perror("testspeed: unable to connect to server");
71 language
= cupsLangDefault();
74 * Do requests 100 times...
79 for (elapsed
= 0.0, i
= 0; i
< 100; i
++)
85 * Build a CUPS_GET_PRINTERS request, which requires the following
89 * attributes-natural-language
94 request
->request
.op
.operation_id
= CUPS_GET_PRINTERS
;
95 request
->request
.op
.request_id
= 1;
97 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_CHARSET
,
98 "attributes-charset", NULL
, cupsLangEncoding(language
));
100 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_LANGUAGE
,
101 "attributes-natural-language", NULL
, language
->language
);
103 gettimeofday(&start
, NULL
);
104 response
= cupsDoRequest(http
, request
, "/printers/");
105 gettimeofday(&end
, NULL
);
109 if (response
!= NULL
)
112 elapsed
+= (end
.tv_sec
- start
.tv_sec
) +
113 0.000001 * (end
.tv_usec
- start
.tv_usec
);
117 printf("Total elapsed time for %d requests was %.1fs (%.3fs/r)\n",
118 i
, elapsed
, elapsed
/ i
);
125 * End of "$Id: testspeed.c,v 1.4 2002/01/02 17:59:18 mike Exp $".