Performance problems with HTTPText. This is a test program for the problems.

Dependencies:   EthernetNetIf mbed

Revision:
0:fd0a4a9e317c
Child:
1:20a89656f772
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 08 22:06:26 2010 +0000
@@ -0,0 +1,84 @@
+/**
+ * Performance problems with HTTPText.
+ * 
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#include "mbed.h"
+#include "EthernetNetIf.h"
+#include "HTTPClient.h"
+
+EthernetNetIf netif;
+Timer timer;
+
+void test(int bufsiz);
+int main(void);
+
+/**
+ * Execute the test.
+ *
+ * @param bufsiz Buffer size of a HTTPText.
+ */
+void test(int bufsiz) {
+    HTTPClient client;
+    HTTPMap map;
+    HTTPText text("text/html", bufsiz);
+    
+    int sizelist[10] = {
+        8,
+        16,
+        32,
+        64,
+        128,
+        256,
+        512,
+        1024,
+        2048,
+        4096
+    };
+
+    printf("(Buffer size of a HTTPText : %d)\n", bufsiz);    
+    printf("+---------+--------+----+\n");
+    printf("|File size|Time[ms]|Code|\n");
+    printf("+---------+--------+----+\n");
+    for (int i = 0; i < sizeof(sizelist) / sizeof(sizelist[0]); i++) {
+        char url[256];
+        sprintf(url, "http://mbed.org/media/uploads/shintamainjp/textfile_%dbytes.txt", sizelist[i]);
+        timer.stop();
+        timer.reset();
+        timer.start();
+        HTTPResult r = client.get(url, &text);
+        timer.stop();
+        printf("|%9d|%8d|%4d|\n", sizelist[i], timer.read_ms(), client.getHTTPResponseCode());
+    }
+    printf("+---------+--------+----+\n");
+}
+
+/**
+ * Entry point.
+ */
+int main(void) {
+    int bufsizlist[10] = {
+        8,
+        16,
+        32,
+        64,
+        128,
+        256,
+        512,
+        1024,
+        2048,
+        4096
+    };
+
+    EthernetErr ethErr = netif.setup();
+    if (ethErr) {
+        error("Network setup failed.\n");
+    }
+
+    for (int i = 0; i < sizeof(bufsizlist) / sizeof(bufsizlist[0]); i++) {
+        printf("\n");
+        test(bufsizlist[i]);
+    }
+}