javascript associative vs non-associative arrays (v18)

Revision 18 of this benchmark created on


Preparation HTML

<script>
  var arr = [];
  var asc = {};
  var asd = {};
  var ase = [];
  var asf = [];
  var asg0, asg1, asg2;

  asg0 = 0;
  asg1 = 1;
  asg2 = 2;
  
  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

Ready to run.

Testing in
TestOps/sec
Object access with numbers
asc.i0;
asc.i1;
asc.i2;
ready
Object Access without numbers
asd.a;
asd.b;
asd.c;
ready
Associative Array with numbers
ase['i0'];
ase['i1'];
ase['i2'];
ready
Associative Array without numbers
asf['a'];
asf['b'];
asf['c'];
ready
Array access
arr[0];
arr[1];
arr[2];
ready
Variable access
asg1;
asg2;
asg3;
ready

Revisions

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