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 |
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);
const regexp = /[\x00-\x1f\x7f]/g;
for (const char of chars) {
newChars.push(char.replace(regexp, ""));
}
console.log(newChars);
for (const char of chars) {
newChars.push(char.replace(/[\x00-\x1f\x7f]/g, ""));
}
console.log(newChars);
const regexp = new RegExp("[\x00-\x1f\x7f]");
for (const char of chars) {
newChars.push(char.replace(regexp, ""));
}
console.log(newChars);
for (const char of chars) {
newChars.push(char.replace(new RegExp("[\x00-\x1f\x7f]"), ""));
}
console.log(newChars);