Skip to content

Instantly share code, notes, and snippets.

@JustinChristensen
Created January 19, 2015 23:00
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 JustinChristensen/66168d00834b98398429 to your computer and use it in GitHub Desktop.
Save JustinChristensen/66168d00834b98398429 to your computer and use it in GitHub Desktop.
doubling_test.js
(function () {
function getKey() {
var table = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_,;()*";
var tableLength = table.length;
var arr = [];
var i = 0;
var KEY_LENGTH = 20;
for (i = 0, len = Math.floor(Math.random() * KEY_LENGTH); i < len; i++) {
arr[i] = table.charAt(Math.floor(Math.random() * tableLength));
}
return arr.join("");
}
var hash;
var N;
var k;
var i;
var key;
var END = Math.pow(2, 24);
for (N = 1; N < END; N *= 2) {
hash = {};
console.log("N: " + N);
for (k = 0; k < N; k++) {
key = getKey();
if (k < N - 1) {
hash[key] = k;
}
else {
console.profile(N + " put");
hash[key] = k;
console.profileEnd(N + " put");
console.profile(N + " get");
i = hash[key];
console.profileEnd(N + " get");
}
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment