Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JS Find vs FindIndex vs loop
(version: 1)
Comparing performance of:
Find vs FindIndex vs loop
Created:
one month ago
by:
Guest
Jump to the latest result
Script Preparation code:
var hasZero = []; var withoutZero = []; for (var i = 0; i < 10000; i++) { hasZero.push(Math.floor(Math.random() * 1000)); withoutZero.push(Math.floor(Math.random() * 1000) + 1) }
Tests:
Find
var tempResult = !!Math.round(Math.random()) ? hasZero.find(v => v === 0) : withoutZero.find(v => v === 0);
FindIndex
var tempResult = !!Math.round(Math.random()) ? hasZero.findIndex(v => v === 0) : withoutZero.findIndex(v => v === 0);
loop
var index = 0; var tempResult = null; if (!!Math.round(Math.random())) { for (let item of hasZero) { if (item == 0) { tempResult = index; break; } else index++; } } else { for (let item of withoutZero) { if (item == 0) { tempResult = index; break; } else index++; } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Find
FindIndex
loop
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:150.0) Gecko/20100101 Firefox/150.0
Browser/OS:
Firefox 150 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Find
17751.5 Ops/sec
FindIndex
18352.0 Ops/sec
loop
20983.4 Ops/sec
Related benchmarks:
Som vs findIndex
JS Find vs FindIndex
Includes vs. IndexOf vs. Filter vs. Find vs. FindIndex vs. Some
Some vs. Find
Some vs indexOf vs Includes vs Find
Some vs. Find for Paulius
Includes vs. IndexOf vs. Filter vs. Find vs. FindIndex vs. Some vs. Map
some vs. findIndex vs find
Some vs. Filter vs. indexOf vs. Includes vs. Find vs. findIndex performance
Comments
Confirm delete:
Do you really want to delete benchmark?