Created
January 12, 2017 09:44
-
-
Save cevek/d443f69219f8a630449b6ed9fd99e838 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 str = ["d2rqw3","q5mkv6","68heu9","jbc8tc","we72sf","ch1tri","pjtnql","p5mohp","3ipjbo","evse5n","qbv8wn","4p13qm","g53vkl","ri6qek","5v9l8j","hbcg2i","sofath","74i5ng","ihl0hf","tunsbe","8aqn5d","jnthwd","v3wcqc","9h27kb","ku52ea","wa7u89","anap28","m3djt7","0ggen6","btj9h5","n9m4b4","1mow53","d2rqw3","ofulq2","2t0gk1","e93be0","pm667w","42911v","ffbssu","qsenmt","58higs","glkdar","s1n84r","6eq2vq","hrsupp","t7vpjo","7l1kdn","j14f7m","ue7a1l","8ra4sk","k7cwmj","vkfrgi","a0imah","ldlh4h","wqobvg","b6r6pf","mju1je","0wwtdd","cd2o7c","nq5j1b","268dsa","djb8m9","owe3g8","3cgva7","epjq47","q5mkv6","4ipfp5","fvsaj4","rbv5d3","5p1072","h53s11","si6ms0","6v9hlw","ibccfv","tof79v","84i23u","jhktut","uunoos","9aqjir","kntecq","w3w96p","ah240o","lu4vrn","0a7qlm","bnalfl","n3dg9l","1ggb3k","ctj5uj","o9m0oi","2mosih","e2rncg","pfui6f","3t0d0e","f937rd","qm62lc","528ufb","gfbp9b","rsek3a","68heu9","hlk9o8"]; | |
var hash = {}; | |
for (let i = 0; i < str.length; i++) { | |
hash[str[i]] = i; | |
} | |
function getHash(hash, prop) { | |
var x; | |
console.time(prop); | |
for (var i = 0; i < 1e8; i++) { | |
x = hash[prop]; | |
} | |
console.timeEnd(prop); | |
return x; | |
} | |
getHash(hash, 'd2rqw3'); | |
//9h27kb | |
//ku52ea | |
//58higs | |
//6v9hlw | |
//fvsaj4 | |
var a = ['fvsaj4', '6v9hlw', 'notfound']; | |
for (let i = 0; i < a.length; i++) { | |
// getHash(hash, str[i]); | |
getHash(hash, a[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment