Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 YaBrowser/24.1.0.0 Safari/537.36
Yandex Browser 24
Mac OS X 10.15.7
Desktop
2 years ago
replace inline regex
4.5M/s
brackets and slice
4.3M/s
brackets and substr (legacy)
4.3M/s
brackets and substring
4.3M/s
substring and slice
4.3M/s
substr and substr (legacy)
4.3M/s
substring and substring
4.2M/s
replace compiled regex var
3.5M/s
View exact numbers
Test name Executions per second
replace inline regex 4,453,898 Ops/sec
brackets and slice 4,303,533 Ops/sec
brackets and substr (legacy) 4,298,690 Ops/sec
brackets and substring 4,258,596 Ops/sec
substring and slice 4,255,451 Ops/sec
substr and substr (legacy) 4,250,736 Ops/sec
substring and substring 4,218,631 Ops/sec
replace compiled regex var 3,548,083 Ops/sec
Script Preparation code:
Tests: