jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Testing data access methods for url based keys.
var methods = ['http', 'https'],
words = "collaboratively administrate empowered markets via plug and play networks dynamically procrastinate b2c users after installed base benefits dramatically visualize customer directed convergence without revolutionary roi efficiently unleash cross media information without cross media value quickly maximize timely deliverables for real-time schemas dramatically maintain clicks and mortar solutions without functional solutions completely synergize resource sucking relationships via premier niche markets professionally cultivate one to one customer service with robust ideas dynamically innovate resource leveling customer service for state of the art customer service".split(" "),
tlds = ['com', 'net', 'org', 'co.uk', 'co', 'us', 'sc', 'sexy', 'domains', 'ninja', 'club', 'dating', 'movie', 'travel'],
urls = [],
urlsToFind = [],
urlsHashTable = {},
urlsCollection = [],
urlsIndexedHashTable = {},
urlsIndexedCollection = {},
urlsAlphaHashA = {},
urlsAlphaCollA = [],
urlsAlphaHashB = {},
urlsAlphaCollB = [],
urlsAlphaHashC = {},
urlsAlphaCollC = [],
urlsAlphaHashD = {},
urlsAlphaCollD = [],
urlsAlphaHashE = {},
urlsAlphaCollE = [],
urlsAlphaHashF = {},
urlsAlphaCollF = [],
urlsAlphaHashG = {},
urlsAlphaCollG = [],
urlsAlphaHashH = {},
urlsAlphaCollH = [],
urlsAlphaHashI = {},
urlsAlphaCollI = [],
urlsAlphaHashJ = {},
urlsAlphaCollJ = [],
urlsAlphaHashK = {},
urlsAlphaCollK = [],
urlsAlphaHashL = {},
urlsAlphaCollL = [],
urlsAlphaHashM = {},
urlsAlphaCollM = [],
urlsAlphaHashN = {},
urlsAlphaCollN = [],
urlsAlphaHashO = {},
urlsAlphaCollO = [],
urlsAlphaHashP = {},
urlsAlphaCollP = [],
urlsAlphaHashQ = {},
urlsAlphaCollQ = [],
urlsAlphaHashR = {},
urlsAlphaCollR = [],
urlsAlphaHashS = {},
urlsAlphaCollS = [],
urlsAlphaHashT = {},
urlsAlphaCollT = [],
urlsAlphaHashU = {},
urlsAlphaCollU = [],
urlsAlphaHashV = {},
urlsAlphaCollV = [],
urlsAlphaHashW = {},
urlsAlphaCollW = [],
urlsAlphaHashX = {},
urlsAlphaCollX = [],
urlsAlphaHashY = {},
urlsAlphaCollY = [],
urlsAlphaHashZ = {},
urlsAlphaCollZ = [];
function getRandomEntry(arr) {
return arr[Math.floor(Math.random() * (arr.length-1))];
}
function findIndexInCollectionByUrl(collection, url) {
for (var i = 0; i < collection.length; i++) {
if (collection[i].url == url) return i;
}
}
function findIndexByUrl(url) {
return findIndexInCollectionByUrl(urlsCollection, url);
}
function findIndexByUrlWithGroup(group, url) {
for (var i = 0; i < urlsCollection[group].length; i++) {
if (urlsCollection[group][i].url == url) return i;
}
}
function fileAlphaHash(letter, url, obj) {
switch(letter.toLowerCase()) {
case 'a':
urlsAlphaHashA[url] = obj;
break;
case 'b':
urlsAlphaHashB[url] = obj;
break;
case 'c':
urlsAlphaHashC[url] = obj;
break;
case 'd':
urlsAlphaHashD[url] = obj;
break;
case 'e':
urlsAlphaHashE[url] = obj;
break;
case 'f':
urlsAlphaHashF[url] = obj;
break;
case 'g':
urlsAlphaHashG[url] = obj;
break;
case 'h':
urlsAlphaHashH[url] = obj;
break;
case 'i':
urlsAlphaHashI[url] = obj;
break;
case 'j':
urlsAlphaHashJ[url] = obj;
break;
case 'k':
urlsAlphaHashK[url] = obj;
break;
case 'l':
urlsAlphaHashL[url] = obj;
break;
case 'm':
urlsAlphaHashM[url] = obj;
break;
case 'n':
urlsAlphaHashN[url] = obj;
break;
case 'o':
urlsAlphaHashO[url] = obj;
break;
case 'p':
urlsAlphaHashP[url] = obj;
break;
case 'q':
urlsAlphaHashQ[url] = obj;
break;
case 'r':
urlsAlphaHashR[url] = obj;
break;
case 's':
urlsAlphaHashS[url] = obj;
break;
case 't':
urlsAlphaHashT[url] = obj;
break;
case 'u':
urlsAlphaHashU[url] = obj;
break;
case 'v':
urlsAlphaHashV[url] = obj;
break;
case 'w':
urlsAlphaHashW[url] = obj;
break;
case 'x':
urlsAlphaHashW[url] = obj;
break;
case 'y':
urlsAlphaHashY[url] = obj;
break;
case 'z':
urlsAlphaHashZ[url] = obj;
break;
}
}
function fileAlphaColl(letter, url, obj) {
switch(letter.toLowerCase()) {
case 'a':
urlsAlphaCollA[findIndexInCollectionByUrl(urlsAlphaCollA, url)] = obj;
break;
case 'b':
urlsAlphaCollB[findIndexInCollectionByUrl(urlsAlphaCollB, url)] = obj;
break;
case 'c':
urlsAlphaCollC[findIndexInCollectionByUrl(urlsAlphaCollC, url)] = obj;
break;
case 'd':
urlsAlphaCollD[findIndexInCollectionByUrl(urlsAlphaCollD, url)] = obj;
break;
case 'e':
urlsAlphaCollE[findIndexInCollectionByUrl(urlsAlphaCollE, url)] = obj;
break;
case 'f':
urlsAlphaCollF[findIndexInCollectionByUrl(urlsAlphaCollF, url)] = obj;
break;
case 'g':
urlsAlphaCollG[findIndexInCollectionByUrl(urlsAlphaCollG, url)] = obj;
break;
case 'h':
urlsAlphaCollH[findIndexInCollectionByUrl(urlsAlphaCollH, url)] = obj;
break;
case 'i':
urlsAlphaCollI[findIndexInCollectionByUrl(urlsAlphaCollI, url)] = obj;
break;
case 'j':
urlsAlphaCollJ[findIndexInCollectionByUrl(urlsAlphaCollJ, url)] = obj;
break;
case 'k':
urlsAlphaCollK[findIndexInCollectionByUrl(urlsAlphaCollK, url)] = obj;
break;
case 'l':
urlsAlphaCollL[findIndexInCollectionByUrl(urlsAlphaCollL, url)] = obj;
break;
case 'm':
urlsAlphaCollM[findIndexInCollectionByUrl(urlsAlphaCollM, url)] = obj;
break;
case 'n':
urlsAlphaCollN[findIndexInCollectionByUrl(urlsAlphaCollN, url)] = obj;
break;
case 'o':
urlsAlphaCollO[findIndexInCollectionByUrl(urlsAlphaCollO, url)] = obj;
break;
case 'p':
urlsAlphaCollP[findIndexInCollectionByUrl(urlsAlphaCollP, url)] = obj;
break;
case 'q':
urlsAlphaCollQ[findIndexInCollectionByUrl(urlsAlphaCollQ, url)] = obj;
break;
case 'r':
urlsAlphaCollR[findIndexInCollectionByUrl(urlsAlphaCollR, url)] = obj;
break;
case 's':
urlsAlphaCollS[findIndexInCollectionByUrl(urlsAlphaCollS, url)] = obj;
break;
case 't':
urlsAlphaCollT[findIndexInCollectionByUrl(urlsAlphaCollT, url)] = obj;
break;
case 'u':
urlsAlphaCollU[findIndexInCollectionByUrl(urlsAlphaCollU, url)] = obj;
break;
case 'v':
urlsAlphaCollV[findIndexInCollectionByUrl(urlsAlphaCollV, url)] = obj;
break;
case 'w':
urlsAlphaCollW[findIndexInCollectionByUrl(urlsAlphaCollW, url)] = obj;
break;
case 'x':
urlsAlphaCollX[findIndexInCollectionByUrl(urlsAlphaCollX, url)] = obj;
break;
case 'y':
urlsAlphaCollY[findIndexInCollectionByUrl(urlsAlphaCollY, url)] = obj;
break;
case 'z':
urlsAlphaCollZ[findIndexInCollectionByUrl(urlsAlphaCollZ, url)] = obj;
break;
}
}
for(var a = 0; a < 1000; a++) {
url = getRandomEntry(methods) + '://';
url += getRandomEntry(words) + '-';
url += getRandomEntry(words) + '.';
url += getRandomEntry(words) + '-';
url += getRandomEntry(words) + '.';
url += getRandomEntry(tlds) + '/';
url += getRandomEntry(words) + '-';
url += getRandomEntry(words) + '/';
url += getRandomEntry(words) + '/';
url += getRandomEntry(words) + '/';
url += getRandomEntry(words) + '#';
url += getRandomEntry(words) + '-';
url += getRandomEntry(words);
urls.push(url);
if(a % 3 == 0) urlsToFind.push(url);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Hashtable |
| ready |
Collection |
| ready |
HashTable Method Indexed |
| ready |
Collections Method Indexed |
| ready |
HashTable First Letter Indexed |
| ready |
Collections First Letter Indexed |
| ready |
HashTable First Letter Indexed Separate Vars |
| ready |
Collections First Letter Indexed Separate Vars |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.