javascript associative vs non-associative arrays

JavaScript performance comparison

Revision 23 of this test case created

Preparation code

<script>
  var arr = [];
  var asc = {};
  var asd = {};
  var ase = [];
  var asf = [];
 
  arr[0] = 0;
  arr[1] = 1;
  arr[2] = 2;
 
  asc.i0 = 0;
  asc.i1 = 1;
  asc.i2 = 2;
 
  asd.a = 0;
  asd.b = 1;
  asd.c = 2;
 
  ase['i0'] = 0;
  ase['i1'] = 1;
  ase['i2'] = 2;
 
  asf['a'] = 0;
  asf['b'] = 1;
  asf['c'] = 2;
</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
Object access with numbers
// async test
asc.i0;
asc.i1;
asc.i2;
pending…
Object Access without numbers
// async test
asd.a;
asd.b;
asd.c;
pending…
Associative Array with numbers
// async test
ase['i0'];
ase['i1'];
ase['i2'];
pending…
Associative Array without numbers
// async test
asf['a'];
asf['b'];
asf['c'];
pending…
Array access
// async test
arr[0];
arr[1];
arr[2];
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