`;
const escapeElement = document.createElement('span');
const escapeTextNode = document.createTextNode('');
escapeElement.append(escapeTextNode);
function escape(str) {
escapeTextNode.textContent = str;
return escapeElement.innerHTML;
}
let i = 0;
for (; i < 10000; i++) {
escape(htmlStr);
};}
var testCase = {'fn': fn, 'defer': deferred};
suite.add(testName, testCase);
var testName = 'Option node';
var deferred = false;
var fn = function() {const htmlStr = `
`;
const option = new Option('');
function escape(str) {
option.label = str;
return option.label;
}
let i = 0;
for (; i < 10000; i++) {
escape(htmlStr);
};}
var testCase = {'fn': fn, 'defer': deferred};
suite.add(testName, testCase);
var testName = 'Replace A';
var deferred = false;
var fn = function() {const htmlStr = `
`;
function escape(str) {
const E = [
['&', '&'],
['<', '<'],
['>', '>'],
["'", '''],
['"', '"'],
];
return (v) => E.reduce((r, e) => str.replaceAll(e[0], e[1]), v);
}
let i = 0;
for (; i < 10000; i++) {
escape(htmlStr);
};}
var testCase = {'fn': fn, 'defer': deferred};
suite.add(testName, testCase);
var testName = 'Replace B';
var deferred = false;
var fn = function() {const htmlStr = `
`;
function escape(str) {
return str.replaceAll('&', '&')
.replaceAll('<', '<')
.replaceAll('>', '>')
.replaceAll("'", ''')
.replaceAll('"', '"');
return (v) => E.reduce((r, e) => str.replaceAll(e[0], e[1]), v);
}
let i = 0;
for (; i < 10000; i++) {
escape(htmlStr);
};}
var testCase = {'fn': fn, 'defer': deferred};
suite.add(testName, testCase);
var testName = 'Replace C';
var deferred = false;
var fn = function() {const htmlStr = `
`;
function escape(str) {
return ('' + str).replace(/[^\w. ]/gi, c => '' + c.charCodeAt(0) + ';')
}
let i = 0;
for (; i < 10000; i++) {
escape(htmlStr);
};}
var testCase = {'fn': fn, 'defer': deferred};
suite.add(testName, testCase);
suite.on('start', pageController.onStartHandler);
suite.on('cycle', pageController.onCycleHandler);
suite.on('abort', pageController.onAbortHandler);
suite.on('error', pageController.onErrorHandler);
suite.on('reset', pageController.onResetHandler);
suite.on('complete', pageController.onCompleteHandler);
suite.run({ 'async': true });