Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133
Mac OS X 10.15.7
Desktop
one month ago
Test name Executions per second
Literal RegExps 43989120.0 Ops/sec
Constructed RegExps 10458753.0 Ops/sec
HTML Preparation code:
AخA
 
1
<!--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'))