Skip to content

Instantly share code, notes, and snippets.

@brunoventura
Created April 6, 2016 00:56
Show Gist options
  • Save brunoventura/9fb30bc6b89325cd76e4408fb47ab512 to your computer and use it in GitHub Desktop.
Save brunoventura/9fb30bc6b89325cd76e4408fb47ab512 to your computer and use it in GitHub Desktop.
'use strict';
const obj = {};
const map = new Map;
const total = 99999999;
for (var i = 0; i < 100000; i++) {
obj['_'+i] = true;
map.set('_'+i, true);
}
let init = new Date().getTime();
let count = 0
while (count < total) {
map['_10'];
map['ok'];
map['_99999'];
map['_2398413984'];
count++;
}
console.log(new Date().getTime() - init);
init = new Date().getTime();
count = 0
while (count < total) {
obj['_10'];
obj['ok'];
obj['_99999'];
obj['_2398413984'];
count++;
}
console.log(new Date().getTime() - init);
init = new Date().getTime();
count = 0
while (count < total) {
map.get('_10') // true
map.get('ok') // undefined
map.get('_99999') // true
map.get('_2398413984') // undefined
count++;
}
console.log(new Date().getTime() - init);
init = new Date().getTime();
count = 0
while (count < total) {
obj._10 // true
obj.ok // false
obj._99999 // true
obj._2398413984 // false
count++;
}
console.log(new Date().getTime() - init);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment