Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Chrome 124
Mac OS X 10.15.7
Desktop
2 years ago
replace inline regex
9.8M/s
substring and substring
8.8M/s
substring and slice
8.8M/s
brackets and substring
8.7M/s
brackets and slice
8.7M/s
substr and substr (legacy)
8.7M/s
brackets and substr (legacy)
8.7M/s
replace compiled regex var
7.4M/s
View exact numbers
Test name Executions per second
replace inline regex 9,757,264 Ops/sec
substring and substring 8,783,657 Ops/sec
substring and slice 8,760,006 Ops/sec
brackets and substring 8,730,362 Ops/sec
brackets and slice 8,727,196 Ops/sec
substr and substr (legacy) 8,721,100 Ops/sec
brackets and substr (legacy) 8,700,009 Ops/sec
replace compiled regex var 7,419,259 Ops/sec
Script Preparation code:
Tests: