Let's say I am forced to sleep in this barbaric way.
I cannot use events (such as setTimeout), it isn't in the constraints of the problem and doing such a thing has already been previously discussed in depth.
function sleep(milliseconds) {
var start = new Date().getTime();
while (new Date().getTime() < start + milliseconds){
// need some NOP here
}
}
All I wanna know is, can you think of something I could stick in there? Preferably a single statement that takes a long time to run (maybe that takes time to malloc a huge region?)
Taking a ton of CPU time is fine, even though it isn't technically a NOP. Additionally, oversleeping is fine. Freezing the browser is not a concern. I am most interested in minimizing the amount of statements that run during the sleep duration, so basically: the longest-executing single statement that doesn't really "do" anything.