Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Test forEach (findIndex) vs forEach (include)
Test forEach (findIndex) vs forEach (include)
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/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
SmallList ForEach => findIndex in BigList
41.1 Ops/sec
BigList ForEach => includes in SmallTestList
92.0 Ops/sec
Script Preparation code:
var bigList = new Array(15000); bigList.fill({ id: 0 }); bigList = bigList.map((el, idx) => el.id = idx); var smallIdList = new Array(1500); smallIdList.fill({ id: 0 }); smallIdList = smallIdList.map((el) => el.id = Math.floor(Math.random() * 15000))
Tests:
SmallList ForEach => findIndex in BigList
smallIdList.forEach((itemId) => { const index = bigList.findIndex((bigListItem) => bigListItem.id === itemId); });
BigList ForEach => includes in SmallTestList
bigList.forEach((bigListItem, index) => { smallIdList.includes(bigListItem.id) });