Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Chrome 120
Mac OS X 10.15.7
Desktop
2 years ago
replace inline regex
10.6M/s
substring and slice
9.8M/s
substring and substring
9.8M/s
substr and substr (legacy)
9.8M/s
brackets and substring
9.7M/s
brackets and slice
9.7M/s
brackets and substr (legacy)
9.6M/s
replace compiled regex var
8.1M/s
View exact numbers
Test name Executions per second
replace inline regex 10,622,341 Ops/sec
substring and slice 9,849,384 Ops/sec
substring and substring 9,804,127 Ops/sec
substr and substr (legacy) 9,794,082 Ops/sec
brackets and substring 9,703,462 Ops/sec
brackets and slice 9,656,170 Ops/sec
brackets and substr (legacy) 9,626,269 Ops/sec
replace compiled regex var 8,106,982 Ops/sec
Script Preparation code:
Tests: