Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
array vs hashmap lookup
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
array lookup
125548.9 Ops/sec
hash lookup
4953642.5 Ops/sec
Script Preparation code:
function uuid() { return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) ); } window.versionsArray = Array(100).fill({ type: 'module' }).map(a => ({ ...a, id: uuid(), archiveId: uuid() })) window.versionsHash = versionsArray.reduce((hash, version) => { if (!hash[version.type]) hash[version.type] = {} hash[version.type][version.id] = version.archiveId return hash; }, {}) window.locateId = versionsArray[70].id window.locateArchiveId = versionsArray[70].archiveId
Tests:
array lookup
const foundVersionArchiveId = window.versionsArray.find(v => v.type === 'module' && v.id === window.locateId) console.assert(foundVersionArchiveId === window.locateArchiveId)
hash lookup
const foundVersionArchiveId = window.versionsHash.module?.[locateId] console.assert(foundVersionArchiveId === window.locateArchiveId)