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 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0
Browser:
Firefox 136
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
array lookup
100971.5 Ops/sec
hash lookup
6283405.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)