Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
how fast is regex2?
(version: 1)
Comparing performance of:
instantiate new regex vs use existing regex vs just make a string
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const prepared = /[.*+?^${}()|[\]\\]/g;
Tests:
instantiate new regex
const blah = "whatever" const r = blah.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
use existing regex
const blah = "whatever" const r = blah.replace(prepared, "\\$&")
just make a string
const blah = "foo"
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
instantiate new regex
use existing regex
just make a string
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/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
instantiate new regex
14204612.0 Ops/sec
use existing regex
14546226.0 Ops/sec
just make a string
167660256.0 Ops/sec
Related benchmarks:
string replaceAll test
replace regex vs. multiple replaceAll calls - fixed
sa sad test
RegEx.test vs. String.includes vs. String.match vs String.replace
RegEx.test vs. String.includes vs. String.match vs String.replace vs String.replace classic
rgx replace with if
replaceAll vs regex replace vs regex replace2
how fast is regex?
how fast is regex3?
Comments
Confirm delete:
Do you really want to delete benchmark?