13ms and the lack of change sounds suspiciously like you are actually measuring your screen refresh rate. Would that be 75Hz ?
1000 / 75 gives 13.3333 etc which means a measurement of 13 or occasionally 14.
If the measurement loop includes Flip then you could optimise the operation to nothing and the measurement would still be 13ms at 75Hz.
In Debug mode, the code is taking longer than one cycle so gets pushed to the next multiple. For 40ms this could be more than say 2 screen updates and so gives you 3 * 13.3 = 40ms. For the original at 108ms, 8 * 13.3333 gives 106. Not a perfect match but not too far away.
Just a guess.
1000 / 75 gives 13.3333 etc which means a measurement of 13 or occasionally 14.
If the measurement loop includes Flip then you could optimise the operation to nothing and the measurement would still be 13ms at 75Hz.
In Debug mode, the code is taking longer than one cycle so gets pushed to the next multiple. For 40ms this could be more than say 2 screen updates and so gives you 3 * 13.3 = 40ms. For the original at 108ms, 8 * 13.3333 gives 106. Not a perfect match but not too far away.
Just a guess.