Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JS Split VS RegExp
(version: 1)
Comparing performance of:
Split vs RegExp
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); }
Tests:
Split
/*When writing async/deferred tests, use `deferred.resolve()` to mark test as done*/ const hasSubdomain = (hostname) => { return hostname.split('.').length > 2; }; hasSubdomain('pixel.barion.com');
RegExp
const hasSubdomain = (hostname) => { return /^[^.]+\.[^.]+\./.test(hostname); }; hasSubdomain('pixel.barion.com');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Split
RegExp
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Browser/OS:
Chrome 132 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Split
12315885.0 Ops/sec
RegExp
15790837.0 Ops/sec
Related benchmarks:
Assigning new variable
Luxon vs
undefined to boolean
Regex starts with A or B vs startsWith
js mul vs pow
Splti vs Trim vs replace className
test early return
test assign path
URL object vs split to get canonical url
Comments
Confirm delete:
Do you really want to delete benchmark?