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.6M/s
brackets and substr (legacy)
8.8M/s
brackets and slice
8.7M/s
brackets and substring
8.7M/s
substring and substring
8.7M/s
substr and substr (legacy)
8.7M/s
substring and slice
8.6M/s
replace compiled regex var
7.4M/s
View exact numbers
Test name Executions per second
replace inline regex 9,645,709 Ops/sec
brackets and substr (legacy) 8,753,478 Ops/sec
brackets and slice 8,745,949 Ops/sec
brackets and substring 8,741,656 Ops/sec
substring and substring 8,701,053 Ops/sec
substr and substr (legacy) 8,689,656 Ops/sec
substring and slice 8,649,592 Ops/sec
replace compiled regex var 7,356,690 Ops/sec
Script Preparation code:
Tests: