Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Unnecessary non-capturing groups
https://stackoverflow.com/questions/45291700/javascript-regex-non-capture-faster-than-no-parenthesis-at-all
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/136.0.0.0 Safari/537.36 Edg/136.0.0.0
Browser:
Chrome 136
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
indexOf
103.2M/s
anotherUnneededNonCapture
7.0M/s
anotherNoNonCapture
4.0M/s
noNonCaptureRE
3.8M/s
unneededNonCaptureRE
3.7M/s
View exact numbers
Test name
Executions per second
✓
indexOf
103,205,960 Ops/sec
anotherUnneededNonCapture
6,989,348 Ops/sec
anotherNoNonCapture
3,985,725 Ops/sec
noNonCaptureRE
3,813,553 Ops/sec
unneededNonCaptureRE
3,745,181 Ops/sec
Script Preparation code:
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')