Last active
June 16, 2016 09:29
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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