Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
String Array: Includes vs regex test vs indexOf
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/109.0.0.0 Safari/537.36
Browser:
Chrome 109
Operating system:
Windows
Device Platform:
Desktop
Date tested:
6 months ago
Test name
Executions per second
Array.prototype.includes()
7989194.0 Ops/sec
RegExp.prototype.test()
199674.6 Ops/sec
Array.prototype.indexOf()
7271719.5 Ops/sec
Script Preparation code:
var targetString = 'could' var stringArray = [ "Hopes", "and", "dreams", "were", "dashed", "that", "day.", "It", "should", "have", "been", "expected,", "but", "it", "still", "came", "as", "a", "shock.", "The", "warning", "signs", "had", "been", "ignored", "in", "favor", "of", "the", "possibility,", "however", "remote,", "that", "it", "could", "actually", "happen.", "That", "possibility", "had", "grown", "from", "hope", "to", "an", "undeniable", "belief", "it", "must", "be", "destiny.", "That", "was", "until", "it", "wasn't", "and", "the", "hopes", "and", "dreams", "came", "crashing", "down." ]
Tests:
Array.prototype.includes()
stringArray.includes(targetString)
RegExp.prototype.test()
new RegExp(stringArray.join('|')).test(targetString)
Array.prototype.indexOf()
stringArray.indexOf(targetString)