Run details:
Mozilla/5.0 (Linux; Android 11; SM-A107F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.104 Mobile Safari/537.36
Chrome Mobile 96
Android
Mobile
3 years ago
Test name Executions per second
replace 18320.1 Ops/sec
replaceAll 18417.3 Ops/sec
replace in a loop without g flag 749.8 Ops/sec
replace in a loop, count matches with g flag, replace without g flag 1037.1 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