[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17400 - libmicrohttpd/src/testcurl
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17400 - libmicrohttpd/src/testcurl |
Date: |
Wed, 12 Oct 2011 11:25:53 +0200 |
Author: grothoff
Date: 2011-10-12 11:25:52 +0200 (Wed, 12 Oct 2011)
New Revision: 17400
Modified:
libmicrohttpd/src/testcurl/daemontest_post_loop.c
Log:
speed up test case, print performance
Modified: libmicrohttpd/src/testcurl/daemontest_post_loop.c
===================================================================
--- libmicrohttpd/src/testcurl/daemontest_post_loop.c 2011-10-12 08:42:49 UTC
(rev 17399)
+++ libmicrohttpd/src/testcurl/daemontest_post_loop.c 2011-10-12 09:25:52 UTC
(rev 17400)
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <gauger.h>
#ifndef WINDOWS
#include <unistd.h>
@@ -38,7 +39,7 @@
#define POST_DATA "<?xml version='1.0'
?>\n<xml>\n<data-id>1</data-id>\n</xml>\n"
-#define LOOPCOUNT 10
+#define LOOPCOUNT 1000
static int oneone;
@@ -329,7 +330,8 @@
}
for (i = 0; i < LOOPCOUNT; i++)
{
- fprintf (stderr, ".");
+ if (99 == i % 100)
+ fprintf (stderr, ".");
c = curl_easy_init ();
cbc.pos = 0;
buf[0] = '\0';
@@ -390,6 +392,8 @@
if ((CURLM_OK == curl_multi_timeout (multi, &ctimeout)) &&
(ctimeout < timeout) && (ctimeout >= 0))
timeout = ctimeout;
+ if (c == NULL)
+ timeout = 0; /* terminate quickly... */
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
select (max + 1, &rs, &ws, &es, &tv);
@@ -433,7 +437,28 @@
}
+/**
+ * Time this round was started.
+ */
+static unsigned long long start_time;
+
+/**
+ * Get the current timestamp
+ *
+ * @return current time in ms
+ */
+static unsigned long long
+now ()
+{
+ struct timeval tv;
+
+ GETTIMEOFDAY (&tv, NULL);
+ return (((unsigned long long) tv.tv_sec * 1000LL) +
+ ((unsigned long long) tv.tv_usec / 1000LL));
+}
+
+
int
main (int argc, char *const *argv)
{
@@ -442,10 +467,46 @@
oneone = NULL != strstr (argv[0], "11");
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
+ start_time = now();
errorCount += testInternalPost ();
+ fprintf (stderr,
+ oneone ? "%s: Sequential POSTs (http/1.1) %f/s" : "%s: Sequential
POSTs (http/1.0) %f/s",
+ "internal select",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0));
+ GAUGER ("internal select",
+ oneone ? "Sequential POSTs (http/1.1)" : "Sequential POSTs
(http/1.0)",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0),
+ "requests/s");
+ start_time = now();
errorCount += testMultithreadedPost ();
+ fprintf (stderr,
+ oneone ? "%s: Sequential POSTs (http/1.1) %f/s" : "%s: Sequential
POSTs (http/1.0) %f/s",
+ "multithreaded post",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0));
+ GAUGER ("Multithreaded select",
+ oneone ? "Sequential POSTs (http/1.1)" : "Sequential POSTs
(http/1.0)",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0),
+ "requests/s");
+ start_time = now();
errorCount += testMultithreadedPoolPost ();
+ fprintf (stderr,
+ oneone ? "%s: Sequential POSTs (http/1.1) %f/s" : "%s: Sequential
POSTs (http/1.0) %f/s",
+ "thread with pool",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0));
+ GAUGER ("thread with pool",
+ oneone ? "Sequential POSTs (http/1.1)" : "Sequential POSTs
(http/1.0)",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0),
+ "requests/s");
+ start_time = now();
errorCount += testExternalPost ();
+ fprintf (stderr,
+ oneone ? "%s: Sequential POSTs (http/1.1) %f/s" : "%s: Sequential
POSTs (http/1.0) %f/s",
+ "external select",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0));
+ GAUGER ("external select",
+ oneone ? "Sequential POSTs (http/1.1)" : "Sequential POSTs
(http/1.0)",
+ (double) 1000 * LOOPCOUNT / (now() - start_time + 1.0),
+ "requests/s");
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
curl_global_cleanup ();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17400 - libmicrohttpd/src/testcurl,
gnunet <=