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

Dependencies:   EthernetNetIf mbed

Files at this revision

API Documentation at this revision

Comitter:
shintamainjp
Date:
Fri Oct 08 22:06:26 2010 +0000
Child:
1:20a89656f772
Commit message:

Changed in this revision

EthernetNetIf.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetNetIf.lib	Fri Oct 08 22:06:26 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/EthernetNetIf/#bc7df6da7589
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient.lib	Fri Oct 08 22:06:26 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/HTTPClient/#d0be6af2d1db
--- /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]);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 08 22:06:26 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e