Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.58 Safari/537.36
Chrome 93
Linux
Desktop
3 years ago
Test name Executions per second
replace 102259.4 Ops/sec
replaceAll 81434.0 Ops/sec
replace in a loop without g flag 3924.9 Ops/sec
replace in a loop, count matches with g flag, replace without g flag 5522.9 Ops/sec
Script Preparation code:
Tests:
  • replace

  • replaceAll

  • replace in a loop without g flag

  • replace in a loop, count matches with g flag, replace without g flag