Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.find vs. Map.get small vs Object
Test the performance of Array.find vs. Map.get, with various array sizes, and with/without conversion from array to map
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/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.find, 100 elements
15575202.0 Ops/sec
Map.get, 100 elements
109111376.0 Ops/sec
Object, 100 elements
106611992.0 Ops/sec
Script Preparation code:
function getRandomElement(id) { return { id, a: Math.random(), b: Math.random(), c: Math.random(), } } function getArray(length) { const result = []; for (let i = 0; i < length; i++) { result.push(getRandomElement(i)) } return result; } function arrayToMap(array) { return new Map(array.map(el => [el.id, el])); } function getRandomInt(max) { return Math.floor(Math.random() * max); } array_small = getArray(100); array_large = getArray(1000000); map_small = arrayToMap(array_small); map_large = arrayToMap(array_large); obj_small = Object.fromEntries(map_small)
Tests:
Array.find, 100 elements
const target = getRandomInt(99); array_small.find(el => el.id === target);
Map.get, 100 elements
const target = getRandomInt(99); map_small.get(target);
Object, 100 elements
const target = getRandomInt(99); obj_small[target]