Last active
December 20, 2020 18:06
-
-
Save scpedicini/7101bfd651add70df43834b052be3ab9 to your computer and use it in GitHub Desktop.
Block CPU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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