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.0M/s
substr and substr (legacy)
9.1M/s
substring and slice
9.1M/s
brackets and substr (legacy)
9.1M/s
brackets and slice
9.1M/s
substring and substring
9.0M/s
brackets and substring
9.0M/s
replace compiled regex var
7.6M/s
View exact numbers
Test name Executions per second
replace inline regex 10,042,948 Ops/sec
substr and substr (legacy) 9,128,211 Ops/sec
substring and slice 9,104,589 Ops/sec
brackets and substr (legacy) 9,080,730 Ops/sec
brackets and slice 9,058,538 Ops/sec
substring and substring 9,047,524 Ops/sec
brackets and substring 9,043,653 Ops/sec
replace compiled regex var 7,571,494 Ops/sec
Script Preparation code:
Tests: