Array vs Map vs Obj accsess

JavaScript performance comparison

Test case created by stasj145

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  const testMap = new Map();
  const testArray = [];
  const testObj = [];
  let x, y, i, v;
  
  testMap.set('firstLevelGroup', [1,1]);
  testMap.set('secondLevelGroup', [2,2]);
  testMap.set('thirdLevelGroup', [3,3]);
  testMap.set('node', [4,4]);
  
  testArray.push([1,1]);
  testArray.push([2,2]);
  testArray.push([3,3]);
  testArray.push([4,4]);
  

};
</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
map
testMap.get('firstLevelGroup')[0] += 1;
testMap.get('secondLevelGroup')[0] += 1;
testMap.get('thirdLevelGroup')[0] += 1;
testMap.get('node')[0] += 1;
pending…
array
testArray[0][0] += 1;
testArray[1][0] += 1;
testArray[2][0] += 1;
testArray[3][0] += 1;
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