Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.find vs. Map.get bis
(version: 1)
Test the performance of Array.find vs. Map.get, with various array sizes, and with/without conversion from array to map
Comparing performance of:
Array.find, 10 000 elements vs Map.get, 10 000 elements
Created:
8 months ago
by:
Guest
Jump to the latest result
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); array_small.find(el => el.id === target);
Map.get, 10 000 elements
const target = getRandomInt(9999); map_small.get(target);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array.find, 10 000 elements
Map.get, 10 000 elements
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Browser/OS:
Chrome 139 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.find, 10 000 elements
239744.9 Ops/sec
Map.get, 10 000 elements
168205360.0 Ops/sec
Related benchmarks:
Array.find vs. Map.get
Array.find vs. Map.getss
Array.find vs. Map.get 2
Array.find vs. Map.get 300
Array.find vs Map.get
Array.find vs. Map.get smaller
Array.find vs. Map.get small
Array.find vs. Map.get small vs Object
Array.find vs. Map.get for small intss
Comments
Confirm delete:
Do you really want to delete benchmark?