Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Create a map once then query it, or query each value.
when receiving a large result, should you query said result and reused the cache value, or should you search the value each time.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Browser:
Chrome 127
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Search the array.
2563.3 Ops/sec
Make a map then search.
106.0 Ops/sec
Script Preparation code:
var arr = []; var i = 0; while (i <= 1E5) arr[i] = { id: i++ };
Tests:
Search the array.
let j = 0; while (j <= 1E5) { const item = arr.find(e => e.id == j++); }
Make a map then search.
let myMap = new Map(arr.map(e => ([e.id, e]))); let j = 0; while (j <= 1E5) { const item = myMap.get(j++); }