Script Preparation code:
AخA
 
String.prototype.replaceAll1 = function(search, replacement) {
    var target = this;
    return target.replace(new RegExp(search, 'g'), replacement);
};
String.prototype.replaceAll2 = function(search, replacement) {
    var target = this;
    return target.replaceAll(search, replacement);
};
Tests:
  • replace regrex

     
    "this is it".replace(/ /g, "+");
  • replace all

     
    "this is it".replaceAll(" ", "+");
  • split join

     
    "this is it".split(" ").join("+");
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    replace regrex
    replace all
    split join

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Android 10; Mobile; rv:107.0) Gecko/107.0 Firefox/107.0
Firefox Mobile 107 on Android
View result in a separate tab
Test name Executions per second
replace regrex 3246578.8 Ops/sec
replace all 7195226.0 Ops/sec
split join 3665524.2 Ops/sec