Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
Chrome 59
Linux
Other
7 years ago
Test name Executions per second
unneededNonCaptureRE 2384496.2 Ops/sec
noNonCaptureRE 2380136.8 Ops/sec
anotherUnneededNonCapture 3488588.2 Ops/sec
anotherNoNonCapture 2545632.2 Ops/sec
indexOf 12354694.0 Ops/sec
Script Preparation code:
AخA
 
var loremString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
var unneededNonCaptureRE = /(?:z)+/
var noNonCaptureRE = /z+/
var anotherUnneededNonCapture = /lab(?:o)rum/
var anotherNoNonCapture = /laborum/
Tests:
  • unneededNonCaptureRE

     
    unneededNonCaptureRE.exec(loremString)
  • noNonCaptureRE

     
    noNonCaptureRE.exec(loremString)
  • anotherUnneededNonCapture

     
    anotherUnneededNonCapture.exec(loremString)
  • anotherNoNonCapture

     
    anotherNoNonCapture.exec(loremString)
  • indexOf

     
    loremString.indexOf('laborum')