Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
RegExp constructor vs literal vs premade, constructing in function
(version: 0)
Testing performance when using a new RegExp object vs a literal regex
Comparing performance of:
new RegExp() vs RegExp() factory vs Literal vs Literal premade
Created:
6 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function getReConstructor() { return new RegExp('^[0-9a-fA-F]{24}$'); } function getReFactory() { return RegExp('^[0-9a-fA-F]{24}$'); } function getReLiteral() { return /^[0-9a-fA-F]{24}$/; } var premadeLiteral = /^[0-9a-fA-F]{24}$/; function getRePremadeLiteral() { return premadeLiteral; }
Tests:
new RegExp()
getReConstructor().test('132abc67219f019afe12901a')
RegExp() factory
getReFactory().test('132abc67219f019afe12901a')
Literal
getReLiteral().test('132abc67219f019afe12901a')
Literal premade
getRePremadeLiteral().test('132abc67219f019afe12901a')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
new RegExp()
RegExp() factory
Literal
Literal premade
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
RegExp constructor vs literal, constructing in function
RegExp constructor vs literal vs premade, constructing in function, inline the test
RegExp constructor vs literal vs premade, constructing in function, inline the test 2
RegExp constructor vs literals, with variations
Comments
Confirm delete:
Do you really want to delete benchmark?