Performance issue with streams and uasyncio on ESP32
Posted: Wed Aug 03, 2022 2:59 pm
Hi guys,
I am testing the server code by Peter from here on my ESP32 dev board: micropython-async/v3/as_drivers/client_server/userver.py
If I change the way I read from the stream on line 34 by calling sreader.read() rather than readline(), then there is around 3x to 4x performance boost. I am attempting to read a small HTTP header from a client, so readline() is quite useful in parsing the header as each header is separated line by line but if I read the whole thing in one go, it is way faster. If I have to use the read() function, then I have to manage the buffer myself in Python.
Does anyone have any ideas what could be the reason and what is the best way to approach this ?
Many thanks
I am testing the server code by Peter from here on my ESP32 dev board: micropython-async/v3/as_drivers/client_server/userver.py
If I change the way I read from the stream on line 34 by calling sreader.read() rather than readline(), then there is around 3x to 4x performance boost. I am attempting to read a small HTTP header from a client, so readline() is quite useful in parsing the header as each header is separated line by line but if I read the whole thing in one go, it is way faster. If I have to use the read() function, then I have to manage the buffer myself in Python.
Does anyone have any ideas what could be the reason and what is the best way to approach this ?
Many thanks