]>
Commit | Line | Data |
---|---|---|
85a106ae | 1 | /* |
71fe22b7 | 2 | * "$Id: testspeed.c,v 1.2 2000/01/04 13:46:10 mike Exp $" |
85a106ae | 3 | * |
4 | * Scheduler speed test for the Common UNIX Printing System (CUPS). | |
5 | * | |
71fe22b7 | 6 | * Copyright 1997-2000 by Easy Software Products. |
85a106ae | 7 | * |
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 | |
13 | * at: | |
14 | * | |
15 | * Attn: CUPS Licensing Information | |
16 | * Easy Software Products | |
17 | * 44141 Airport View Drive, Suite 204 | |
18 | * Hollywood, Maryland 20636-3111 USA | |
19 | * | |
20 | * Voice: (301) 373-9603 | |
21 | * EMail: cups-info@cups.org | |
22 | * WWW: http://www.cups.org | |
23 | * | |
24 | * Contents: | |
25 | * | |
26 | */ | |
27 | ||
28 | /* | |
29 | * Include necessary headers... | |
30 | */ | |
31 | ||
32 | #include <stdio.h> | |
33 | #include <stdlib.h> | |
34 | #include <ctype.h> | |
35 | #include <sys/time.h> | |
36 | #include <cups/cups.h> | |
37 | #include <cups/language.h> | |
38 | #include <cups/debug.h> | |
39 | ||
40 | ||
41 | /* | |
42 | * 'main()' - Send multiple IPP requests and report on the average response | |
43 | * time. | |
44 | */ | |
45 | ||
46 | int | |
47 | main(int argc, /* I - Number of command-line arguments */ | |
48 | char *argv[]) /* I - Command-line arguments */ | |
49 | { | |
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 */ | |
56 | end; /* End time */ | |
57 | double elapsed; /* Elapsed time */ | |
58 | ||
59 | ||
60 | if (argc > 1) | |
61 | http = httpConnect(argv[1], ippPort()); | |
62 | else | |
63 | http = httpConnect("localhost", ippPort()); | |
64 | ||
65 | if (http == NULL) | |
66 | { | |
67 | perror("testspeed: unable to connect to server"); | |
68 | return (1); | |
69 | } | |
70 | ||
71 | language = cupsLangDefault(); | |
72 | ||
73 | /* | |
74 | * Do requests 100 times... | |
75 | */ | |
76 | ||
77 | printf("Testing: "); | |
78 | ||
79 | for (elapsed = 0.0, i = 0; i < 100; i ++) | |
80 | { | |
81 | putchar('>'); | |
82 | fflush(stdout); | |
83 | ||
84 | /* | |
85 | * Build a CUPS_GET_PRINTERS request, which requires the following | |
86 | * attributes: | |
87 | * | |
88 | * attributes-charset | |
89 | * attributes-natural-language | |
90 | */ | |
91 | ||
92 | request = ippNew(); | |
93 | ||
94 | request->request.op.operation_id = CUPS_GET_PRINTERS; | |
95 | request->request.op.request_id = 1; | |
96 | ||
97 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, | |
98 | "attributes-charset", NULL, cupsLangEncoding(language)); | |
99 | ||
100 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, | |
101 | "attributes-natural-language", NULL, language->language); | |
102 | ||
103 | gettimeofday(&start, NULL); | |
104 | response = cupsDoRequest(http, request, "/printers/"); | |
105 | gettimeofday(&end, NULL); | |
106 | ||
107 | putchar('<'); | |
108 | ||
109 | if (response != NULL) | |
110 | ippDelete(response); | |
111 | ||
112 | elapsed += (end.tv_sec - start.tv_sec) + | |
113 | 0.000001 * (end.tv_usec - start.tv_usec); | |
114 | } | |
115 | ||
116 | puts(""); | |
117 | printf("Total elapsed time for %d requests was %.1fs (%.3fs/r)\n", | |
118 | i, elapsed, elapsed / i); | |
119 | ||
120 | return (0); | |
121 | } | |
122 | ||
123 | ||
124 | /* | |
71fe22b7 | 125 | * End of "$Id: testspeed.c,v 1.2 2000/01/04 13:46:10 mike Exp $". |
85a106ae | 126 | */ |