Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object arrays: findIndex vs for loop (large array)
(version: 1)
Testing finding an object array via findIndex or by using a for loop
Comparing performance of:
findIndex vs for loop
Created:
one year ago
by:
Guest
Go to the latest result
Script Preparation code:
var arr = new Array(100000); arr.fill({ id: 0 }); arr = arr.map((el, idx) => el.id = idx); var foo = Math.floor(Math.random() * 15000);
Tests:
findIndex
arr.findIndex((itm) => itm.id === foo);
for loop
for (let i = 0; i < arr.length; i++) { if (arr[i].id === foo) break; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
findIndex
for loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser/OS:
Chrome 138 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
findIndex
31K/s
for loop
6K/s
View exact numbers
Test name
Executions per second
✓
findIndex
31,278 Ops/sec
for loop
5,942 Ops/sec
Related benchmarks
Object arrays: findIndex vs for loop
Object arrays: findIndex vs for loop (Small amount of entries)
findIndex vs for loop with plain number array
Object arrays: findIndex vs for loop start from some index
Comments
Confirm delete:
Do you really want to delete benchmark?