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
9.8M/s
substring and substring
9.0M/s
substring and slice
8.9M/s
brackets and substring
8.9M/s
substr and substr (legacy)
8.9M/s
brackets and substr (legacy)
8.8M/s
brackets and slice
8.7M/s
replace compiled regex var
7.4M/s
View exact numbers
Test name Executions per second
replace inline regex 9,799,354 Ops/sec
substring and substring 8,968,641 Ops/sec
substring and slice 8,920,272 Ops/sec
brackets and substring 8,913,684 Ops/sec
substr and substr (legacy) 8,862,811 Ops/sec
brackets and substr (legacy) 8,804,068 Ops/sec
brackets and slice 8,741,910 Ops/sec
replace compiled regex var 7,413,654 Ops/sec
Script Preparation code:
Tests: