Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Chrome 126
Mac OS X 10.15.7
Desktop
2 years ago
replace inline regex
8.9M/s
brackets and slice
8.2M/s
brackets and substr (legacy)
8.2M/s
substring and slice
8.2M/s
substr and substr (legacy)
8.2M/s
brackets and substring
8.2M/s
substring and substring
8.1M/s
replace compiled regex var
6.8M/s
View exact numbers
Test name Executions per second
replace inline regex 8,889,765 Ops/sec
brackets and slice 8,241,018 Ops/sec
brackets and substr (legacy) 8,218,096 Ops/sec
substring and slice 8,201,998 Ops/sec
substr and substr (legacy) 8,160,310 Ops/sec
brackets and substring 8,158,700 Ops/sec
substring and substring 8,105,806 Ops/sec
replace compiled regex var 6,833,296 Ops/sec
Script Preparation code:
Tests: