Test name | Executions per second |
---|---|
regex-short | 3954213.0 Ops/sec |
upper-short | 5058179.0 Ops/sec |
lower-short | 5161324.5 Ops/sec |
regex-long | 762779.4 Ops/sec |
lower-long | 1533983.5 Ops/sec |
upper-long | 1508668.4 Ops/sec |
const alpha = "Alpha";
const upperAlpha = "ALPHA";
const lowerAlpha = 'alpha';
const regexAlpha = new RegExp(/alpha/i);
var output;
output = regexAlpha.test(alpha);
output = regexAlpha.test(lowerAlpha);
output = regexAlpha.test(upperAlpha);
const alpha = "Alpha";
const upperAlpha = "ALPHA";
const lowerAlpha = 'alpha';
const regexAlpha = new RegExp(/alpha/i);
var output;
output = alpha.toUpperCase() === upperAlpha;
output = alpha.toUpperCase() === upperAlpha;
output = alpha.toUpperCase() === upperAlpha;
const alpha = "Alpha";
const upperAlpha = "ALPHA";
const lowerAlpha = 'alpha';
const regexAlpha = new RegExp(/alpha/i);
var output;
output = alpha.toLowerCase() === lowerAlpha;
output = alpha.toLowerCase() === lowerAlpha;
output = alpha.toLowerCase() === lowerAlpha;
const longString = `The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.`;
const lowerLongString = longString.toLowerCase();
const upperLongString = longString.toUpperCase();
const regexLong = new RegExp(/The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too./i);
var output;
output = regexLong.test(longString);
output = regexLong.test(lowerLongString);
output = regexLong.test(upperLongString);
const longString = `The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.`;
const lowerLongString = longString.toLowerCase();
const upperLongString = longString.toUpperCase();
const regexLong = new RegExp(/The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too./i);
var output;
output = longString.toLowerCase() === lowerLongString;
output = longString.toLowerCase() === lowerLongString;
output = longString.toLowerCase() === lowerLongString;
const longString = `The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.`;
const lowerLongString = longString.toLowerCase();
const upperLongString = longString.toUpperCase();
const regexLong = new RegExp(/The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too./i);
var output;
output = longString.toUpperCase() === upperLongString;
output = longString.toUpperCase() === upperLongString;
output = longString.toUpperCase() === upperLongString;