Test name | Executions per second |
---|---|
Push/Pop | 29460.6 Ops/sec |
ES6 Spread | 4.2 Ops/sec |
Shift/Unshift | 257.9 Ops/sec |
const n = 10000;
const stack = [];
for (let i = 0; i < n; i++) {
stack.push(i);
}
while (stack.length > 0) {
let x = stack.pop();
}
const n = 10000;
let stack = [];
for (let i = 0; i < n; i++) {
stack = [stack, i];
}
let x;
while (stack.length > 0) {
[x, stack] = stack;
}
const n = 10000;
const queue = [];
for (let i = 0; i < n; i++) {
queue.unshift(i);
}
while (queue.length > 0) {
let x = queue.shift();
}