Map Set String vs Index

JavaScript performance comparison

Test case created by ssell

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var map = new Map();
  
  var materialStringId = "amaterial";
  var meshStringId = "amesh";
  
  var materialIntId = 3;
  var meshIntId = 5;
  
  function stringId(x, y)
  {
      return (x + ":" + y);
  }
  
  function cantorId(x, y)
  {
      return ((x + y) * (x + y + 1)) / 2 + y;
  }

};
</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 Key String
map.set(stringId(materialStringId, meshStringId), 1);
pending…
Map Key Cantor
map.set(cantorId(materialIntId, meshIntId), 1);
pending…

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

Compare results of other browsers

0 Comments