Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15
Safari 17
Mac OS X 10.15.7
Desktop
2 years ago
replace inline regex
13.2M/s
brackets and slice
12.4M/s
brackets and substring
12.4M/s
substring and slice
12.2M/s
substring and substring
12.1M/s
brackets and substr (legacy)
11.8M/s
substr and substr (legacy)
11.1M/s
replace compiled regex var
10.3M/s
View exact numbers
Test name Executions per second
replace inline regex 13,246,103 Ops/sec
brackets and slice 12,413,003 Ops/sec
brackets and substring 12,358,229 Ops/sec
substring and slice 12,173,983 Ops/sec
substring and substring 12,129,037 Ops/sec
brackets and substr (legacy) 11,812,455 Ops/sec
substr and substr (legacy) 11,062,281 Ops/sec
replace compiled regex var 10,326,428 Ops/sec
Script Preparation code:
Tests: