Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Chrome 127
Mac OS X 10.15.7
Desktop
one year ago
brackets and substr (legacy)
4.2M/s
replace inline regex
4.2M/s
brackets and substring
4.1M/s
substr and substr (legacy)
4.1M/s
brackets and slice
4.1M/s
substring and slice
4.1M/s
substring and substring
3.7M/s
replace compiled regex var
3.4M/s
View exact numbers
Test name Executions per second
brackets and substr (legacy) 4,163,380 Ops/sec
replace inline regex 4,151,810 Ops/sec
brackets and substring 4,147,575 Ops/sec
substr and substr (legacy) 4,135,329 Ops/sec
brackets and slice 4,125,210 Ops/sec
substring and slice 4,088,993 Ops/sec
substring and substring 3,703,944 Ops/sec
replace compiled regex var 3,370,187 Ops/sec
Script Preparation code:
Tests: