Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
map vs array accessor
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/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Accessing random index in array
28839.4 Ops/sec
Accessing random index in map
23073.2 Ops/sec
Script Preparation code:
window.ITEMS_ARRAY = Array(1000).fill(null).map((item, index) => { return { id: index, name: '10 Portable DVD player', description: 'diam neque vestibulum eget vulputate', price: { value: 66.04, currency: 'CNY' }, status: 'Stocked on demand', statusColor: 'informative', date: new Date(), verified: true }; }); window.ITEMS_MAP = new Map(ITEMS_ARRAY.map((item, index) => [index, item])); window.initialIndex = Math.floor(Math.random() * 500); window.indexes = new Array(500).fill(null).map((item, index) => window.initialIndex + index);
Tests:
Accessing random index in array
window.indexes.forEach((index) => { const smt = window.ITEMS_ARRAY[index]; });
Accessing random index in map
window.indexes.forEach((index) => { const smt = window.ITEMS_MAP.get(index); });