Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Chrome 121
Mac OS X 10.15.7
Desktop
2 years ago
replace inline regex
5.2M/s
brackets and substring
5.1M/s
brackets and slice
5.1M/s
brackets and substr (legacy)
5.1M/s
substr and substr (legacy)
5.1M/s
substring and slice
5.1M/s
substring and substring
5.0M/s
replace compiled regex var
4.1M/s
View exact numbers
Test name Executions per second
replace inline regex 5,174,474 Ops/sec
brackets and substring 5,079,866 Ops/sec
brackets and slice 5,078,972 Ops/sec
brackets and substr (legacy) 5,073,062 Ops/sec
substr and substr (legacy) 5,069,648 Ops/sec
substring and slice 5,063,876 Ops/sec
substring and substring 5,000,356 Ops/sec
replace compiled regex var 4,123,158 Ops/sec
Script Preparation code:
Tests: