Skip to content

Instantly share code, notes, and snippets.

@scpedicini
Last active December 20, 2020 18:06
Show Gist options
  • Save scpedicini/7101bfd651add70df43834b052be3ab9 to your computer and use it in GitHub Desktop.
Save scpedicini/7101bfd651add70df43834b052be3ab9 to your computer and use it in GitHub Desktop.
Block CPU
/**
* Simple CPU-bound blocking operation for testing purposes
* @param baseNumber - higher the value, the longer the operation will block
*/
static blockCPU(baseNumber) {
console.time('blockCPU');
let result = 0;
for (let i = Math.pow(baseNumber, 7); i >= 0; i--) {
result += Math.atan(i) * Math.tan(i);
}
console.timeEnd('blockCPU');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment