Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Chrome 129
Mac OS X 10.15.7
Desktop
one year ago
replace inline regex
7.0M/s
brackets and substring
5.7M/s
brackets and slice
5.7M/s
brackets and substr (legacy)
5.7M/s
substr and substr (legacy)
5.6M/s
substring and slice
5.6M/s
substring and substring
5.6M/s
replace compiled regex var
5.1M/s
View exact numbers
Test name Executions per second
replace inline regex 6,971,048 Ops/sec
brackets and substring 5,676,150 Ops/sec
brackets and slice 5,656,954 Ops/sec
brackets and substr (legacy) 5,655,404 Ops/sec
substr and substr (legacy) 5,625,270 Ops/sec
substring and slice 5,619,248 Ops/sec
substring and substring 5,596,066 Ops/sec
replace compiled regex var 5,117,962 Ops/sec
Script Preparation code:
Tests: