Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126
Mac OS X 10.15.7
Desktop
2 years ago
replace inline regex
12.5M/s
brackets and slice
11.6M/s
brackets and substring
11.5M/s
substring and substring
11.5M/s
substring and slice
11.5M/s
brackets and substr (legacy)
11.5M/s
substr and substr (legacy)
11.5M/s
replace compiled regex var
9.5M/s
View exact numbers
Test name Executions per second
replace inline regex 12,457,305 Ops/sec
brackets and slice 11,552,465 Ops/sec
brackets and substring 11,517,738 Ops/sec
substring and substring 11,504,808 Ops/sec
substring and slice 11,477,781 Ops/sec
brackets and substr (legacy) 11,469,217 Ops/sec
substr and substr (legacy) 11,465,308 Ops/sec
replace compiled regex var 9,497,064 Ops/sec
Script Preparation code:
Tests: