Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
test vs includes
(version: 1)
Comparing regexes with string inclusion
Comparing performance of:
Regex test vs String includes
Created:
11 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var features var isDesktopAlertsAllowed = true var isAlertsM2Allowed = true /*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() { features = [ "Everything in Advisor Core", "Short & leveraged model portfolios", "Client proposals & reports (50/month)", "Custom report slides", "Multiple integrations", "Integration auto-refresh", "PDF broker statement upload", "PMS integrations", "Priority support" ] }
Tests:
Regex test
features.map((feat) => { if (/alerts/i.test(feat) && !isDesktopAlertsAllowed) { return false; } if (isAlertsM2Allowed && /watchlist alerts/i.test(feat)) { return false; } if (!isAlertsM2Allowed && /portfolio alerts/i.test(feat)) { return false; } return true; });
String includes
features.map((feat) => { const lowerFeat = feat.toLowerCase(); if (lowerFeat.includes('alerts') && !isDesktopAlertsAllowed) { return false; } if (isAlertsM2Allowed && lowerFeat.includes('watchlist alerts')) { return false; } if (!isAlertsM2Allowed && lowerFeat.includes('portfolio alerts')) { return false; } return true; });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Regex test
String includes
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
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/OS:
Chrome 134 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Regex test
5250435.5 Ops/sec
String includes
4987891.5 Ops/sec
Related benchmarks:
.endsWith vs last char
varaiabel check includes vs direct
test cross_domain
String .search vs .includes
Regex starts with A or B vs startsWith
set vs uniq
includes vs. word starts with
dadadada
new RegExp vs literal
Comments
Confirm delete:
Do you really want to delete benchmark?