Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Chrome 120
Windows
Desktop
2 years ago
replace inline regex
5.0M/s
substr and substr (legacy)
4.9M/s
brackets and substring
4.9M/s
brackets and substr (legacy)
4.8M/s
brackets and slice
4.8M/s
substring and slice
4.8M/s
substring and substring
4.7M/s
replace compiled regex var
3.9M/s
View exact numbers
Test name Executions per second
replace inline regex 4,965,831 Ops/sec
substr and substr (legacy) 4,866,662 Ops/sec
brackets and substring 4,861,936 Ops/sec
brackets and substr (legacy) 4,819,425 Ops/sec
brackets and slice 4,778,799 Ops/sec
substring and slice 4,753,192 Ops/sec
substring and substring 4,659,244 Ops/sec
replace compiled regex var 3,944,820 Ops/sec
Script Preparation code:
Tests: