Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Usporedba Optimised 10
(version: 0)
Comparing performance of:
Find person in map vs Find person in array
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
window.bigMap = {}; window.bigArray = Array.from({length: 10}).map((_, index) => { const id = "person-id-" + index; const person = { id: id, name: `John Doe ${id}`, age: 18 + Math.floor(Math.random() * 70) }; bigMap[id] = person; return person }) window.generateId = function generateId() { return "person-id-" + Math.floor(Math.random() * 10); } window.getPersonFromMap = function getPersonFromMap() { const id = generateId(); return window.bigMap[id]; } window.getPersonFromArray = function getPersonFromArray() { const id = generateId(); return window.bigArray.find(function findById(p){ return p.id === id; }); } for (let i = 0; i < 10000; i++) { getPersonFromMap() } for (let i = 0; i < 10000; i++) { getPersonFromArray() }
Tests:
Find person in map
getPersonFromMap()
Find person in array
getPersonFromArray()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Find person in map
Find person in array
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser/OS:
Chrome 121 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Find person in map
3034754.2 Ops/sec
Find person in array
3031856.8 Ops/sec
Related benchmarks:
Usporedba
Usporedba 2
Usporedba Optimised
Usporedba Optimised 100
Comments
Confirm delete:
Do you really want to delete benchmark?