Big Array Vs Big Linked List

JavaScript performance comparison

Test case created by Jeremy Diviney

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var LLNode = function() {
  
      this.next = null;
      this.val = '';
  
      };
  
  var listSize = 10000000;
  
  var ary = [];
  var ary2 = new Array(listSize);

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Array
for (var x = 0; x < listSize; x++) {
  ary.push(new LLNode());
}
pending…
Linked List
var lastNode, firstNode;

for (var x = 0; x < listSize; x++) {
  if (x > 0) {
    lastNode.nextNode = (new LLNode());
    lastNode = lastNode.nextNode;
  } else {
    lastNode = new LLNode();
    firstNode = lastNode;
  }
}
pending…
Array pre initialized
for (var x = 0; x < listSize; x++) {
  ary[x] = new LLNode();
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments