isaacs/fast-list — Issue #4: Linked list is not faster than array! It was benchmarked incorrectly.
Author: eldargab
Created: 2012-03-06 12:54:41+00:00
State: open

I tested linked list's performance more carefully and published [results](https://github.com/eldargab/linked-list.js). It turned out that it's not faster.

So why there is 2 times gain in the fast-lists's benchmark:

``` javascript
for (var j = 0; j < l; j ++) {
if (j % 2) list.push(j)
else list.unshift(j)
}
for (var j = 0; j < l; j ++) {
if (j % 2) list.shift(j)
else list.pop(j)
}
```

That's because it fills list with both `unshift()` and `push()` as well as removes with both `pop()` and `shift()`. While pushes - pops of native Array are very fast, shifts - unshifts are slow. But for stacking we are doing only pushes and pops, for queueing - pushes and shifts. Linked list perfoms equally for add - remove operations on both sides. So, while benchmark above is correct for testing linked list's performance it depreciates array results.