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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
indexOf
1650944.2 Ops/sec
includes
1682715.1 Ops/sec
find
1238621.9 Ops/sec
findIndex
1227710.6 Ops/sec
set
14272984.0 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);}