Map vs IterableMap

JavaScript performance comparison

Revision 17 of this test case created

Preparation code

<script>
function IterableMap() {
  this._internal = new Map();
  this._keys = new Array(100);
  this.size = 0;

  this.has = Map.prototype.has.bind(this._internal);
  this.set = Map.prototype.has.bind(this._internal);
  this.get = Map.prototype.has.bind(this._internal);
}
</script>
<script>
Benchmark.prototype.setup = function() {
    var keys = [
      1,
      {},
      [],
      "1"
    ];
   
    var m1 = new Map();
    var m2 = new IterableMap();
};
</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
Map
for(var i = 0, il = keys.length; i < il; i++) {
   m1.set(keys[i], 1);
   m1.has(keys[i]);
   m1.get(keys[i]);
}
pending…
IterableMap
for(var i = 0, il = keys.length; i < il; i++) {
   m2.set(keys[i], 1);
   m2.has(keys[i]);
   m2.get(keys[i]);
}
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