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
9.7M/s
brackets and substring
8.9M/s
substring and slice
8.9M/s
substr and substr (legacy)
8.9M/s
brackets and slice
8.8M/s
brackets and substr (legacy)
8.8M/s
substring and substring
8.8M/s
replace compiled regex var
7.5M/s
View exact numbers
Test name Executions per second
replace inline regex 9,681,007 Ops/sec
brackets and substring 8,908,984 Ops/sec
substring and slice 8,890,265 Ops/sec
substr and substr (legacy) 8,889,442 Ops/sec
brackets and slice 8,838,552 Ops/sec
brackets and substr (legacy) 8,818,653 Ops/sec
substring and substring 8,780,584 Ops/sec
replace compiled regex var 7,531,684 Ops/sec
Script Preparation code:
Tests: