Editing Map vs IterableMap This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <script> /** * A wrapper for a harmony Map that is iterable. * It does not allow deletion of keys however. */ function IterableMap() { var m = new Map(); this._keys = []; } IterableMap.prototype.has = function(key) { return this._internal.has(key); }; IterableMap.prototype.get = function(key) { return this._internal.get(key); }; IterableMap.prototype.set = function(key, val) { var internal = this._internal; return internal.set(key, val); }; IterableMap.prototype.delete = function(key) { return this._internal.delete(key); }; IterableMap.prototype.forEach = function(cb, thisObj) { var keys = this._keys, internal = _internal; for(var i = 0, il = keys.length; i < il; i++) { var key = keys[i]; cb.call(thisObj, internal.get(key), key, this); } }; Object.defineProperty(IterableMap.prototype, "size", { get: function() { return this._internal.size; } }); </script> Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) var keys = [ 1, {}, [], "1" ]; Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code var map = new Map(); for(var i = 0, il = keys.length; i < il; i++) { map.set(keys[i], 1); map.has(keys[i]); map.get(keys[i]); } Test 2 Title Async (check if this is an asynchronous test) Code var map = new IterableMap(); for(var i = 0, il = keys.length; i < il; i++) { map.set(keys[i], 1); map.has(keys[i]); map.get(keys[i]); }