Linked list vs array

JavaScript performance comparison

Revision 4 of this test case created by Jamie Hill

Preparation code

<script>
var Obj = function(a){ this.a = a; };
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
array
var arr = [];
arr.push(new Obj(1));
arr.push(new Obj(2));
arr.push(new Obj(3));
arr.push(new Obj(4));
arr.push(new Obj(5));
arr.push(new Obj(6));
arr.push(new Obj(7));
arr.push(new Obj(8));
arr.push(new Obj(9));
arr.push(new Obj(10));
 
pending…
List
var head = new Obj(1), o;
o = (head.next = new Obj(2));
o = (o.next = new Obj(3));
o = (o.next = new Obj(4));
o = (o.next = new Obj(5));
o = (o.next = new Obj(6));
o = (o.next = new Obj(7));
o = (o.next = new Obj(8));
o = (o.next = new Obj(9));
o = (o.next = new Obj(10));
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. Here’s a list of current revisions for this page:

0 comments

Add a comment