Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Regex vs String.includes in Array.filter v2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser:
Chrome 137
Operating system:
Linux
Device Platform:
Desktop
Date tested:
11 months ago
Test name
Executions per second
Regex match
1366281.9 Ops/sec
String includes with toLowerCase
973803.1 Ops/sec
Script Preparation code:
var array = ["PHV Versicherung", "Rücktrittsversicherung", "Lebensversicherung"] var searchStrings = ["rücktritt", "versicher", "rung", "P"]
Tests:
Regex match
for(let i = 0; i < searchStrings; i++) { array.filter(str => { const rgx = new RegExp(searchStrings[i], "i"); return str.match(rgx); }) }
String includes with toLowerCase
for(let i = 0; i < searchStrings; i++) { array.filter(str => { return str.toLowerCase().includes(searchStrings[i].toLowerCase()); }) }