SolidSoils / Arduino

C# .NET - Arduino library supporting simultaneous serial ASCII, Firmata and I2C communication
https://solidsoils.github.io/Arduino/index.html
BSD 2-Clause "Simplified" License
200 stars 61 forks source link

Severe performance impact of Debug.Write in SerialDataReceived #29

Closed jeroenwalter closed 3 years ago

jeroenwalter commented 5 years ago

I have an Arduino sketch that produces about 20 sysex commands per second, each about 30 bytes long. Writing every single byte to the Debug output has a severe impact on the performance of ArduinoSession. This causes serial data to be queued and processed seconds after they have been received from the Arduino. I can understand the need to view the raw serial data, but it would be nice if this can conditionally be turned off.

SolidSoils commented 5 years ago

I will replace the DEBUG verb with another word.

jeroenwalter commented 5 years ago

I have addressed this in my branch by creating a simple logger interface and using that instead of Debug.WriteLine(). Then in the program you can implement your own logger class, for instance one the outputs to console or debug window. You then have more control over performance.

SolidSoils commented 3 years ago

Debug.WriteLine statements wrapped in TRACE constants.