Skip to content

Instantly share code, notes, and snippets.

@yuriatgoogle
Created November 12, 2018 18:58
Show Gist options
  • Save yuriatgoogle/5fcb410c4e55770cdd1ab195e907058b to your computer and use it in GitHub Desktop.
Save yuriatgoogle/5fcb410c4e55770cdd1ab195e907058b to your computer and use it in GitHub Desktop.
function blockCpuFor(ms) {
var now = new Date().getTime();
var result = 0
var shouldRun = true;
while(shouldRun) {
result += Math.random() * Math.random();
if (new Date().getTime() > now +ms)
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment