Repository navigation
Add buffering for all output to improve performance with many small strings - #48
Conversation
Update WebServer::write(uint8_t) to write to a buffer instead of sending single characters (or short strings) as small packets. Remove the other signatures of write so that the base ones in the Print class (which call write(uint8_t)) are used instead and simplify the writeP/printP definitions to do this too. This greatly improves the performance of pages which are built from a large number of small strings or values at the expense of a small additional amount of memory (which can be adjusted with the use of a new macro called WEBDUINO_OUTPUT_BUFFER_SIZE) and also saves ~85 bytes of flash.
|
Seems like a good patch to me... does this require a certain version of the Arduino library code in order to use the byte write call from the print methods? |
|
Ah, good point - I hadn't thought of that. Have had a quick check and by the looks of it the |
|
@unwiredben Is there anything else that I can clarify or any adjustments that I should make to this PR before it is okay to merge? |
|
oh, sorry --- just been very busy. I'll merge today. On Tue, Jan 28, 2014 at 11:24 AM, Matt Robinson [email protected]:
|
Add buffering for all output to improve performance with many small strings
The project I'm working on at the moment builds a fairly large table a cell at a time, which takes a noticeable amount of time to load in a browser due to the small packets being sent across the network.
I propose to update
WebServer::write(uint8_t)to write to a buffer instead of sending single characters (or short strings) as small packets. This PR also removes the other signatures ofwriteso that the base ones in thePrintclass (which callwrite(uint8_t)) are used instead and simplifies thewriteP/printPdefinitions to do this too.This greatly improves the performance of pages which are built from a large number of small strings or values at the expense of a small additional amount of memory (which defaults to 32k but can be adjusted with the use of a new macro called
WEBDUINO_OUTPUT_BUFFER_SIZE) and also saves 86 bytes of flash in my particular project into the bargain.