Script Preparation code:
AخA
 
const SIZE = 100000;
var chars = new Array(SIZE);
for (let index = 0; index < SIZE; index++) {
  chars[index] = String.fromCodePoint(
    Math.floor( Math.random() * 0x80 )
  );
}
var newChars = new Array(SIZE);
Tests:
  • Outside, literal

     
    const regexp = /[\x00-\x1f\x7f]/g;
    for (const char of chars) {
      newChars.push(char.replace(regexp, ""));
    }
    console.log(newChars);
  • Inside, literal

     
    for (const char of chars) {
      newChars.push(char.replace(/[\x00-\x1f\x7f]/g, ""));
    }
    console.log(newChars);
  • Outside, object

     
    const regexp = new RegExp("[\x00-\x1f\x7f]");
    for (const char of chars) {
      newChars.push(char.replace(regexp, ""));
    }
    console.log(newChars);
  • Inside, object

     
    for (const char of chars) {
      newChars.push(char.replace(new RegExp("[\x00-\x1f\x7f]"), ""));
    }
    console.log(newChars);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Outside, literal
    Inside, literal
    Outside, object
    Inside, object

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0
Firefox 114 on Windows
View result in a separate tab
Test name Executions per second
Outside, literal 90.7 Ops/sec
Inside, literal 96.2 Ops/sec
Outside, object 114.6 Ops/sec
Inside, object 58.9 Ops/sec