Skip to content

Instantly share code, notes, and snippets.

@arturovt
Created June 6, 2019 22:58
Show Gist options
  • Save arturovt/591a4960e529a0f6ec10b17a55732b2b to your computer and use it in GitHub Desktop.
Save arturovt/591a4960e529a0f6ec10b17a55732b2b to your computer and use it in GitHub Desktop.
const t0 = performance.now();
for (let i = 0; i < 1e9; i++) {}
const t1 = performance.now();
console.log(`"for" loop took ${t1 - t0}ms`);
setTimeout(() => {
const t0setTimeout = performance.now();
for (let i = 0; i < 1e9; i++) {}
const t1setTimeout = performance.now();
console.log(`"for" loop inside "setTimeout" took ${t1setTimeout - t0setTimeout}ms`);
});
setTimeout(() => {
console.log('second "setTimeout" callback');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment