Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3 Safari/605.1.15
Safari 18
Mac OS X 10.15.7
Desktop
one year ago
replace compiled regex var
354.1M/s
replace inline regex
342.6M/s
brackets and slice
302.7M/s
substring and substring
293.4M/s
substring and slice
278.9M/s
brackets and substring
260.7M/s
brackets and substr (legacy)
48.4M/s
substr and substr (legacy)
15.7M/s
View exact numbers
Test name Executions per second
replace compiled regex var 354,093,984 Ops/sec
replace inline regex 342,574,016 Ops/sec
brackets and slice 302,654,592 Ops/sec
substring and substring 293,405,024 Ops/sec
substring and slice 278,910,528 Ops/sec
brackets and substring 260,673,344 Ops/sec
brackets and substr (legacy) 48,421,124 Ops/sec
substr and substr (legacy) 15,696,298 Ops/sec
Script Preparation code:
Tests: