Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Literal vs Constructor RegExp
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0
Browser:
Chrome 140
Operating system:
Windows
Device Platform:
Desktop
Date tested:
10 months ago
Literal RegExps
53.1M/s
Constructed RegExps
10.8M/s
View exact numbers
Test name
Executions per second
✓
Literal RegExps
53,089,132 Ops/sec
Constructed RegExps
10,808,002 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var elements = Array.of(1000000).fill(0) var literalRegexps = elements.map(() => /a/) var constructedRegexps = elements
Tests:
Literal RegExps
literalRegexps.forEach((r) => r.test('aaaa'))
Constructed RegExps
constructedRegexps.forEach((r) => new RegExp('a'.replace(/a/g, 'b')).test('aaaa'))