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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15
Browser:
Safari 17
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
SmallList ForEach => findIndex in BigList
4.8 Ops/sec
BigList ForEach => includes in SmallTestList
67.7 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) });