Tests:
  • replace

    AخA
     
    "this is it".replace(/ /g, "+");
  • replaceAll (regex)

     
    "this is it".replaceAll(/ /g, "+");
  • replaceAll (string)

     
    "this is it".replaceAll(" ", "+");
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    replace
    replaceAll (regex)
    replaceAll (string)

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Chrome 123 on Linux
View result in a separate tab
Test name Executions per second
replace 9506342.0 Ops/sec
replaceAll (regex) 7793659.5 Ops/sec
replaceAll (string) 9194063.0 Ops/sec