Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
String in Array: Set vs IndexOf vs includes vs findIndex vs find
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/137.0.0.0 Safari/537.36
Browser:
Chrome 137
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
set
9.4M/s
indexOf
1.4M/s
includes
1.3M/s
findIndex
900K/s
find
893K/s
View exact numbers
Test name
Executions per second
✓
set
9,356,521 Ops/sec
indexOf
1,400,382 Ops/sec
includes
1,346,178 Ops/sec
findIndex
900,225 Ops/sec
find
892,962 Ops/sec
Script Preparation code:
var arr = []; var i = 0; while (i <= 10) arr[i] = ('' + i++); var testSet = new Set(...arr); var randomKeys = []; i = 0; while (i <= 50) { randomKeys.push(''+Math.round(Math.random(50000) + 5000)); i++; }
Tests:
indexOf
for (const key of randomKeys) {const index = arr.indexOf(key);}
includes
for (const key of randomKeys) {const index = arr.includes(key);}
find
for (const key of randomKeys) {const index = arr.find(item => item == key);}
findIndex
for (const key of randomKeys) {const index = arr.findIndex(item => item == key);}
set
for (const key of randomKeys) {const index = testSet.has(key);}