wait(0) triggers the Windows message system and is of course very slow. Can take several hundred microseconds on slow systems. Don't call it on any iteration in a fast loop.