Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
how fast is regex?
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 15_8_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.7 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 15
Operating system:
iOS 15.8.4
Device Platform:
Mobile
Date tested:
6 months ago
Test name
Executions per second
instantiate new regex
19407704.0 Ops/sec
use existing regex
30937948.0 Ops/sec
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, "\\$&")