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:
10 months ago
by:
Guest
Jump 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:
10 months 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
Test name
Executions per second
findIndex
31278.0 Ops/sec
for loop
5941.9 Ops/sec
Related benchmarks:
Object arrays: findIndex vs for loop
Object arrays: findIndex vs for loop 2
Object arrays: find vs for loop
Object arrays: findIndex vs for loop 22
Object arrays: findIndex vs for loop (length cached)
Object arrays: findIndex vs for loop vs some
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?