aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/perf_get.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/perf_get.c')
-rw-r--r--src/testcurl/perf_get.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/src/testcurl/perf_get.c b/src/testcurl/perf_get.c
index a316ed1e..31dd1177 100644
--- a/src/testcurl/perf_get.c
+++ b/src/testcurl/perf_get.c
@@ -171,7 +171,7 @@ ahc_echo (void *cls,
171 171
172 172
173static int 173static int
174testInternalGet (int poll_flag) 174testInternalGet (int port, int poll_flag)
175{ 175{
176 struct MHD_Daemon *d; 176 struct MHD_Daemon *d;
177 CURL *c; 177 CURL *c;
@@ -179,11 +179,14 @@ testInternalGet (int poll_flag)
179 struct CBC cbc; 179 struct CBC cbc;
180 CURLcode errornum; 180 CURLcode errornum;
181 unsigned int i; 181 unsigned int i;
182 char url[64];
183
184 sprintf(url, "http://localhost:%d/hello_world", port);
182 185
183 cbc.buf = buf; 186 cbc.buf = buf;
184 cbc.size = 2048; 187 cbc.size = 2048;
185 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 188 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag,
186 11080, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 189 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
187 if (d == NULL) 190 if (d == NULL)
188 return 1; 191 return 1;
189 start_timer (); 192 start_timer ();
@@ -191,7 +194,7 @@ testInternalGet (int poll_flag)
191 { 194 {
192 cbc.pos = 0; 195 cbc.pos = 0;
193 c = curl_easy_init (); 196 c = curl_easy_init ();
194 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:11080/hello_world"); 197 curl_easy_setopt (c, CURLOPT_URL, url);
195 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 198 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
196 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 199 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
197 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 200 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -227,7 +230,7 @@ testInternalGet (int poll_flag)
227 230
228 231
229static int 232static int
230testMultithreadedGet (int poll_flag) 233testMultithreadedGet (int port, int poll_flag)
231{ 234{
232 struct MHD_Daemon *d; 235 struct MHD_Daemon *d;
233 CURL *c; 236 CURL *c;
@@ -235,11 +238,14 @@ testMultithreadedGet (int poll_flag)
235 struct CBC cbc; 238 struct CBC cbc;
236 CURLcode errornum; 239 CURLcode errornum;
237 unsigned int i; 240 unsigned int i;
241 char url[64];
242
243 sprintf(url, "http://localhost:%d/hello_world", port);
238 244
239 cbc.buf = buf; 245 cbc.buf = buf;
240 cbc.size = 2048; 246 cbc.size = 2048;
241 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag, 247 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | poll_flag,
242 1081, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 248 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
243 if (d == NULL) 249 if (d == NULL)
244 return 16; 250 return 16;
245 start_timer (); 251 start_timer ();
@@ -247,7 +253,7 @@ testMultithreadedGet (int poll_flag)
247 { 253 {
248 cbc.pos = 0; 254 cbc.pos = 0;
249 c = curl_easy_init (); 255 c = curl_easy_init ();
250 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world"); 256 curl_easy_setopt (c, CURLOPT_URL, url);
251 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 257 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
252 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 258 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
253 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 259 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -282,7 +288,7 @@ testMultithreadedGet (int poll_flag)
282} 288}
283 289
284static int 290static int
285testMultithreadedPoolGet (int poll_flag) 291testMultithreadedPoolGet (int port, int poll_flag)
286{ 292{
287 struct MHD_Daemon *d; 293 struct MHD_Daemon *d;
288 CURL *c; 294 CURL *c;
@@ -290,11 +296,14 @@ testMultithreadedPoolGet (int poll_flag)
290 struct CBC cbc; 296 struct CBC cbc;
291 CURLcode errornum; 297 CURLcode errornum;
292 unsigned int i; 298 unsigned int i;
299 char url[64];
300
301 sprintf(url, "http://localhost:%d/hello_world", port);
293 302
294 cbc.buf = buf; 303 cbc.buf = buf;
295 cbc.size = 2048; 304 cbc.size = 2048;
296 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag, 305 d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | poll_flag,
297 1081, NULL, NULL, &ahc_echo, "GET", 306 port, NULL, NULL, &ahc_echo, "GET",
298 MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END); 307 MHD_OPTION_THREAD_POOL_SIZE, 4, MHD_OPTION_END);
299 if (d == NULL) 308 if (d == NULL)
300 return 16; 309 return 16;
@@ -303,7 +312,7 @@ testMultithreadedPoolGet (int poll_flag)
303 { 312 {
304 cbc.pos = 0; 313 cbc.pos = 0;
305 c = curl_easy_init (); 314 c = curl_easy_init ();
306 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1081/hello_world"); 315 curl_easy_setopt (c, CURLOPT_URL, url);
307 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 316 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
308 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 317 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
309 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 318 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -338,7 +347,7 @@ testMultithreadedPoolGet (int poll_flag)
338} 347}
339 348
340static int 349static int
341testExternalGet () 350testExternalGet (int port)
342{ 351{
343 struct MHD_Daemon *d; 352 struct MHD_Daemon *d;
344 CURL *c; 353 CURL *c;
@@ -355,12 +364,15 @@ testExternalGet ()
355 time_t start; 364 time_t start;
356 struct timeval tv; 365 struct timeval tv;
357 unsigned int i; 366 unsigned int i;
367 char url[64];
368
369 sprintf(url, "http://localhost:%d/hello_world", port);
358 370
359 multi = NULL; 371 multi = NULL;
360 cbc.buf = buf; 372 cbc.buf = buf;
361 cbc.size = 2048; 373 cbc.size = 2048;
362 d = MHD_start_daemon (MHD_USE_DEBUG, 374 d = MHD_start_daemon (MHD_USE_DEBUG,
363 1082, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 375 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
364 if (d == NULL) 376 if (d == NULL)
365 return 256; 377 return 256;
366 start_timer (); 378 start_timer ();
@@ -374,7 +386,7 @@ testExternalGet ()
374 { 386 {
375 cbc.pos = 0; 387 cbc.pos = 0;
376 c = curl_easy_init (); 388 c = curl_easy_init ();
377 curl_easy_setopt (c, CURLOPT_URL, "http://localhost:1082/hello_world"); 389 curl_easy_setopt (c, CURLOPT_URL, url);
378 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 390 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
379 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 391 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
380 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); 392 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1);
@@ -469,6 +481,7 @@ int
469main (int argc, char *const *argv) 481main (int argc, char *const *argv)
470{ 482{
471 unsigned int errorCount = 0; 483 unsigned int errorCount = 0;
484 int port = 1081;
472 485
473 oneone = NULL != strstr (argv[0], "11"); 486 oneone = NULL != strstr (argv[0], "11");
474 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 487 if (0 != curl_global_init (CURL_GLOBAL_WIN32))
@@ -476,13 +489,13 @@ main (int argc, char *const *argv)
476 response = MHD_create_response_from_buffer (strlen ("/hello_world"), 489 response = MHD_create_response_from_buffer (strlen ("/hello_world"),
477 "/hello_world", 490 "/hello_world",
478 MHD_RESPMEM_MUST_COPY); 491 MHD_RESPMEM_MUST_COPY);
479 errorCount += testInternalGet (0); 492 errorCount += testInternalGet (port++, 0);
480 errorCount += testMultithreadedGet (0); 493 errorCount += testMultithreadedGet (port++, 0);
481 errorCount += testMultithreadedPoolGet (0); 494 errorCount += testMultithreadedPoolGet (port++, 0);
482 errorCount += testExternalGet (); 495 errorCount += testExternalGet (port++);
483 errorCount += testInternalGet (MHD_USE_POLL); 496 errorCount += testInternalGet (port++, MHD_USE_POLL);
484 errorCount += testMultithreadedGet (MHD_USE_POLL); 497 errorCount += testMultithreadedGet (port++, MHD_USE_POLL);
485 errorCount += testMultithreadedPoolGet (MHD_USE_POLL); 498 errorCount += testMultithreadedPoolGet (port++, MHD_USE_POLL);
486 MHD_destroy_response (response); 499 MHD_destroy_response (response);
487 if (errorCount != 0) 500 if (errorCount != 0)
488 fprintf (stderr, "Error (code: %u)\n", errorCount); 501 fprintf (stderr, "Error (code: %u)\n", errorCount);