-
-
Save FPG-Alan/2a9d33ff220369e63f0282d893205f31 to your computer and use it in GitHub Desktop.
A CPU intensive operation. Use to test imitate blocking code, test WebWorkers etc.
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
function mySlowFunction(baseNumber) { | |
console.time('mySlowFunction'); | |
let result = 0; | |
for (var i = Math.pow(baseNumber, 7); i >= 0; i--) { | |
result += Math.atan(i) * Math.tan(i); | |
}; | |
console.timeEnd('mySlowFunction'); | |
} | |
mySlowFunction(8); // higher number => more iterations => slower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
另一个版本