Run details:
Mozilla/5.0 (Linux; Android 12) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Mobile Safari/537.36
Chrome Mobile 101
Android
Mobile
2 years ago
Test name Executions per second
replace 68150.3 Ops/sec
replaceAll 70356.7 Ops/sec
replace in a loop without g flag 3295.4 Ops/sec
replace in a loop, count matches with g flag, replace without g flag 4756.0 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