Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.find vs. Map.get 20241610
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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array.find, 10 000 elements
98.2 Ops/sec
Map.get, 10 000 elements
498.5 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(10000); array_large = getArray(1000000); map_small = arrayToMap(array_small); map_large = arrayToMap(array_large);
Tests:
Array.find, 10 000 elements
const target = getRandomInt(9999); for (let i = 0; i < 1000; i++) { array_small.find(el => el.id === target); }
Map.get, 10 000 elements
map_small = arrayToMap(array_small); for (let i = 0; i < 1000; i++) { const target = getRandomInt(9999); map_small.get(target); }