By adding log() you are actually slowing down the process a bit to display the log-text.
Now may be your code is so written that different events are fired on after another affecting the cpu, or one event is pulling the cpu down (it happens in windows programming too). So the log at that event is giving the cpu time to another event, making the experience faster.