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
brackets and substr (legacy)
3.6M/s
brackets and slice
3.5M/s
substr and substr (legacy)
3.5M/s
brackets and substring
3.5M/s
replace inline regex
3.3M/s
substring and slice
3.2M/s
substring and substring
2.8M/s
replace compiled regex var
2.6M/s
View exact numbers
Test name Executions per second
brackets and substr (legacy) 3,596,698 Ops/sec
brackets and slice 3,541,670 Ops/sec
substr and substr (legacy) 3,513,924 Ops/sec
brackets and substring 3,474,946 Ops/sec
replace inline regex 3,277,785 Ops/sec
substring and slice 3,214,062 Ops/sec
substring and substring 2,797,578 Ops/sec
replace compiled regex var 2,581,674 Ops/sec
Script Preparation code:
Tests: