Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
includes vs indexOf vs findIndex vs Regex
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
12152275.0 Ops/sec
findIndex
9860651.0 Ops/sec
Regex
34153348.0 Ops/sec
includes
12211410.0 Ops/sec
Script Preparation code:
var data = "aaaa"; var falseData = "bbbb"; var matchers = [ ...Array.from({length: 30}).map((_, i) => "dummy" + i), "aaaa", ...Array.from({length: 30}).map((_, i) => "dummyII" + i)]; var regex = new RegExp(`(^|\\.)(${matchers.join('|')})$`);
Tests:
indexOf
const res = matchers.indexOf(data) >= 0 const fRes = matchers.indexOf(falseData) >= 0
findIndex
const res = matchers.findIndex(key => key === data) >= 0 const fRes = matchers.findIndex(key => key === falseData) >= 0
Regex
const res = regex.test(data); const fRes = regex.test(falseData);
includes
const res = matchers.includes(data) const fRes = matchers.includes(falseData)