Maps vs Arrays

JavaScript performance comparison

Revision 6 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var map = {
    "0": 0,
    "1": 1,
    "2": 2,
    "3": 3,
    "4": 4,
    "5": 5,
    "6": 6,
    "7": 7,
    "8": 8,
    "9": 9
  };
  
  var arr = [0,1,2,3,4,5,6,7,8,9];
  var rand = Math.floor(Math.random() * 10);

};

Benchmark.prototype.teardown = function() {
  rand = Math.floor(Math.random() * 10);

};
</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
Maps
map[rand] !== undefined;
pending…
Arrays
arr[rand] !== undefined;
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