Created
November 3, 2021 18:24
-
-
Save arj03/4eee4b4950916e2cd1b011f600964d3a to your computer and use it in GitHub Desktop.
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
let l = [] | |
let counter; | |
function setup() { | |
counter = 0 | |
for (var i = 0; i < 10000; ++i) { | |
l.push(() => counter += 1) | |
} | |
} | |
setup() | |
console.time('shift') | |
while (l.length) l.shift()() | |
console.timeEnd('shift') | |
console.log(l, counter) | |
setup() | |
console.time('clear') | |
for (var i = 0, len = l.length; i < len; ++i) | |
l[i]() | |
l = [] | |
console.timeEnd('clear') | |
console.log(l, counter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment