I have some code I'm working on for an arduino project. My main loop is taking too much time to cycle at the moment, so I started commenting out sections and measuring the cycles/second of the main loop with the millis() function so I could see what parts of the code are taking the longest to execute.
Now, I have 2 if statements and 1 while loop that contain code around 10kb in size, but they are never found to be true unless the arduino gets a very specific serial signal. However, when I commented them out the cycles/second of my main loop increase by the tens of thousands...
Just in case something in my code was making the if and while statements true I entered 0 in all the brackets. Yet, they still seem to slow down my main loop by tens of thousands of cycles...
Can if or while loops slow down the main loop if they are never executed? I know the if or while check is in itself a command and requires clock cycles to make the check, but it shouldn't affect the speed when there are only 2 or 3 if statements in the whole main loop.
p.s. no, I am not doing a do-while loop, just the regular while, so it's never being executed.