-->
Page 1 of 1

Side effect of adding too many yield()

PostPosted: Fri Aug 19, 2016 6:33 am
by helpme
Adding yield() will reduce random resets. Sometimes, for the sake of stability, one can have too many yield() in the code. What is the side effect of having too many yield() in the code?

Re: Side effect of adding too many yield()

PostPosted: Mon Aug 22, 2016 11:10 am
by mrburnette
helpme wrote:Adding yield() will reduce random resets. Sometimes, for the sake of stability, one can have too many yield() in the code. What is the side effect of having too many yield() in the code?


A delay(0) is executed at the repetition of every loop() and in a simple program that means thousands of calls into the backend where yield() lives. There is no issues with this approach ...

But, IMO, what you should be doing is using millis() to benchmark your code to determine where you actually needs the delay(0) or yield(). Profiling your code is something you should be doing anyway to get an impression of what is eating time in your loop. I have an example here.


Ray