Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Chrome 122
Windows
Desktop
2 years ago
replace inline regex
4.1M/s
brackets and slice
3.7M/s
brackets and substr (legacy)
3.7M/s
substring and slice
3.6M/s
substr and substr (legacy)
3.6M/s
brackets and substring
3.6M/s
substring and substring
3.6M/s
replace compiled regex var
3.2M/s
View exact numbers
Test name Executions per second
replace inline regex 4,052,067 Ops/sec
brackets and slice 3,661,374 Ops/sec
brackets and substr (legacy) 3,651,684 Ops/sec
substring and slice 3,646,882 Ops/sec
substr and substr (legacy) 3,641,087 Ops/sec
brackets and substring 3,627,322 Ops/sec
substring and substring 3,591,696 Ops/sec
replace compiled regex var 3,151,350 Ops/sec
Script Preparation code:
Tests: