Skip to content

Instantly share code, notes, and snippets.

Last active October 27, 2023 18:13
  • Star 52 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A CPU intensive operation. Use to test imitate blocking code, test WebWorkers etc.
function mySlowFunction(baseNumber) {
let result = 0;
for (var i = Math.pow(baseNumber, 7); i >= 0; i--) {
result += Math.atan(i) * Math.tan(i);
mySlowFunction(8); // higher number => more iterations => slower
Copy link


Copy link

jecsham commented Apr 21, 2022


Copy link


Copy link

Another function with similar functionality seen elsewhere:

function mySlowFunction(blockTime: number) {
        const now =;
	while( - now < blockTime) {}

mySlowFunction(1000); //millisecond

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment