- Sat Oct 03, 2015 5:01 am
#30398
I've been playing around a little with some limited performance testing of the ESP server and client. I think it should be able to do more than 10 requests per second, but i think there may be some bugs in the ESP code that can slow things down. Don't know how related this is to your question but i'll put it out here as FYI to see if anyone has any ideas:
One thing is with the provided WiFiServer - HelloServer example, running that on an ESP-12 and calling it from a Java program another PC on my local network it takes about 330 milliseconds per request (testing a similar Hello server running on node.js on another PC on the local network does it in about 8 millisecond so its not the network thats slow). It also doesn't vary much running the ESP at 80MHz or 160MHz so its not the CPU thats slowing it down.
However, changing the Java client to do an HTTP HEAD instead of a GET then the requests to the ESP take only about 25 milliseconds.
Updating the ESP HelloServer to do a Serial.print of millis() around the line
Code: Select allserver.send(200, "text/plain", "hello from esp8266!\r\n");
shows that takes nearly 300ms for the GET but only 4ms for the HEAD.
So thats a bit odd, it shouldn't need hundreds of milliseconds to be sending a couple of dozen extra characters. So fixing whatever is going on there could get it up to around 40 requests per second.
There's also something funny in the ESP WiFiClient. If you do two client.print's to send a request then the first print takes around 300 milliseconds. Eg this:
Code: Select all client.print("HEAD /");
client.print(" HTTP/1.1\r\nHost: 192.168.1.96\r\nConnection: close\r\n\r\n");
the first print takes hundreds of milliseconds and the second print just a few milliseconds, where as combining the request into a single print like this:
Code: Select all client.print("HEAD / HTTP/1.1\r\nHost: 192.168.1.96\r\nConnection: close\r\n\r\n");
takes just a few milliseconds.