I was doing some tests to speed up my code, and I realized that having a keyboard in the code slows it down, even if the keyboard is actually never hit.
Here's a code to check it:
% speed testa = rand;ticfor i = 1:1e4if a == 0keyboardendendtocticfor i = 1:1e4if a == 0b = 5^2;endendtoc
Elapsed time is 0.000195 seconds.
Elapsed time is 0.000025 seconds.
How can this be possible?