Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
ForEach then find index vs ForEach then includes vs ForEach then indexOf v2.2
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/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
ForEach then find index
16.0 Ops/sec
ForEach then include
10.9 Ops/sec
ForEach then indexOf
58.8 Ops/sec
Script Preparation code:
var bigList = new Array(15000); bigList.fill(0); bigList = bigList.map((el, idx) => el = idx); var idList = new Array(15000); idList.fill(0); idList = idList.map((el) => el = Math.floor(Math.random() * 15000))
Tests:
ForEach then find index
idList.forEach((itemId) => { bigList.findIndex((bigListItem) => bigListItem === itemId); });
ForEach then include
bigList.forEach((bigListItem, index) => { idList.includes(bigListItem) });
ForEach then indexOf
bigList.forEach((bigListItem, index) => { idList.indexOf(bigListItem) !== -1 });