Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119
Mac OS X 10.15.7
Desktop
2 years ago
replace inline regex
10.1M/s
brackets and substring
9.2M/s
substr and substr (legacy)
9.2M/s
brackets and slice
9.2M/s
brackets and substr (legacy)
9.2M/s
substring and slice
9.2M/s
substring and substring
9.1M/s
replace compiled regex var
7.6M/s
View exact numbers
Test name Executions per second
replace inline regex 10,081,693 Ops/sec
brackets and substring 9,199,997 Ops/sec
substr and substr (legacy) 9,199,708 Ops/sec
brackets and slice 9,189,231 Ops/sec
brackets and substr (legacy) 9,181,157 Ops/sec
substring and slice 9,170,132 Ops/sec
substring and substring 9,119,260 Ops/sec
replace compiled regex var 7,634,958 Ops/sec
Script Preparation code:
Tests: