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)
5.7M/s
substring and slice
5.6M/s
replace inline regex
5.4M/s
substring and substring
5.2M/s
substr and substr (legacy)
4.9M/s
brackets and slice
4.7M/s
replace compiled regex var
4.4M/s
brackets and substring
4.4M/s
View exact numbers
Test name Executions per second
brackets and substr (legacy) 5,686,048 Ops/sec
substring and slice 5,582,044 Ops/sec
replace inline regex 5,405,666 Ops/sec
substring and substring 5,225,286 Ops/sec
substr and substr (legacy) 4,899,598 Ops/sec
brackets and slice 4,711,557 Ops/sec
replace compiled regex var 4,408,420 Ops/sec
brackets and substring 4,369,418 Ops/sec
Script Preparation code:
Tests: