Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Regex Memory Consumption
(version: 0)
Comparing performance of:
Match vs Exec vs Exec Non-Capturing vs Match non capturing
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var acceptHeader = 'image/*, */*'; var mimes = ['image/avif', 'image/webp']; var accepts = 'image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8';
Tests:
Match
var regex = new RegExp(`(${mimes.join('|')})(,|;|$)`, 'i'); var match = accepts.match(regex); if (match){ acceptHeader = match[1]; }
Exec
var regex = new RegExp(`(${mimes.join('|')})(?=,|;|$)`, 'i'); var match = regex.exec(accepts); if (match){ acceptHeader = match[0]; }
Exec Non-Capturing
var regex = new RegExp(`(?:${mimes.join('|')})(?=,|;|$)`, 'i'); var match = regex.exec(accepts); if (match){ acceptHeader = match[0]; }
Match non capturing
var regex = new RegExp(`(?:${mimes.join('|')})(?=,|;|$)`, 'i'); var match = accepts.match(regex); if (match){ acceptHeader = match[0]; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Match
Exec
Exec Non-Capturing
Match non capturing
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0
Browser/OS:
Chrome 145 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Match
1521450.2 Ops/sec
Exec
1544740.0 Ops/sec
Exec Non-Capturing
1524363.5 Ops/sec
Match non capturing
1428027.4 Ops/sec
Related benchmarks:
slice vs capturing group
regular in search & match
Remove MIME type from encoded image URL
fynd test
Comments
Confirm delete:
Do you really want to delete benchmark?