Skip to content

Instantly share code, notes, and snippets.

@timruffles
Last active June 16, 2016 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timruffles/1988c51a0d10f7ce51bcd3e38f9cf52c to your computer and use it in GitHub Desktop.
Save timruffles/1988c51a0d10f7ce51bcd3e38f9cf52c to your computer and use it in GitHub Desktop.
dumb micro bench of es5 vs es6 key value stores. combined set/get. paste into a console or `pbpaste | node` near you! I got es6: 57.397ms es5: 92.984ms for node 6.0.0
var m = new Map;
var o = {};
var value;
var rs = [];
var i = 1e5;
while(i--) rs.push(Math.random().toString())
var i = 1e5; console.time("es6");
while(i--) {
m.set(rs[i], "foo");
value = m.get(rs[(Math.random() * rs.length) | 0])
};
console.timeEnd("es6")
var i = 1e5; console.time("es5");
while(i--) {
o[rs[i]] = "foo";
value = o[rs[(Math.random() * rs.length) | 0]]
};
console.timeEnd("es5")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment