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 (Android 15; Mobile; rv:142.0) Gecko/142.0 Firefox/142.0
Browser:
Firefox Mobile 142
Operating system:
Android
Device Platform:
Mobile
Date tested:
8 months ago
Test name
Executions per second
array lookup
43574.8 Ops/sec
hash lookup
3550318.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)