Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
User Agent search
(version: 1)
Comparing performance of:
Named groups match vs Match + if vs Includes
Created:
one year ago
by:
Guest
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:
Named groups match
/*When writing async/deferred tests, use `deferred.resolve()` to mark test as done*/ Object.entries('Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'.match(/(?<Android>Android)|(?<Windows>Win)|(?<OSX>Mac)|(?<Linux>Linux)|(?<iOS>like Mac)/).groups).find(([key, value]) => value)[0]
Match + if
const match = 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'.match(/Android|Win|Mac|Linux|like Mac/)[0]; let operatingSystem; if (match === 'Win') { operatingSystem = 'Windows'; } else if (match === 'Mac') { operatingSystem = 'OSX'; } else if (match === 'Linux') { operatingSystem = 'Linux'; } else if (match === 'Adnroid') { operatingSystem = 'Android'; } else if (match === 'like Mac') { operatingSystem = 'iOS'; }
Includes
const userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1'; if (userAgent.includes('Win')) { operatingSystem = 'Windows'; } else if (userAgent.includes('Mac')) { operatingSystem = 'OSX'; } else if (userAgent.includes('Linux')) { operatingSystem = 'Linux'; } else if (userAgent.includes('Android')) { operatingSystem = 'Android'; } else if (userAgent.includes('like Mac')) { operatingSystem = 'iOS'; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Named groups match
Match + if
Includes
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Named groups match
1659759.1 Ops/sec
Match + if
17546012.0 Ops/sec
Includes
7149837.5 Ops/sec
Related benchmarks:
Assigning new variable
undefined to boolean
js mul vs pow
Test array ops
test early return
JS Split VS RegExp
Test direct and destructuring performances
Query Element
benchmark for benchmarks
Comments
Confirm delete:
Do you really want to delete benchmark?