Skip to content

Instantly share code, notes, and snippets.

View jpmp0511's full-sized avatar

jpmp0511

View GitHub Profile
@jpmp0511
jpmp0511 / cpu-intensive.js
Created May 26, 2021 04:25 — forked from sorenlouv/cpu-intensive.js
A CPU intensive operation. Use to test imitate blocking code, test WebWorkers etc.
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