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:
9 months ago
use existing regex
30.9M/s
instantiate new regex
19.4M/s
View exact numbers
Test name
Executions per second
✓
use existing regex
30,937,948 Ops/sec
instantiate new regex
19,407,704 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, "\\$&")