jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
<script>
var text = 'asldjasdj lajdask jlasdj alsdj lasj dlkasjdlkajsdlkajs dlkajsdlkajs dlka jsldjs alsdj alksdjlajsif (a < b && c > d) {} // Héllö naõ alsdksdkla lslask dlasj la jdlskj dlsaj dlkasj lajdl askd jlasjd lkajsd lasjd lasjd kasdl asldj aljsdl ajsld jasldk jlsdj dlas jalskdj las dlsjd lajsd lasd lasjd lasjd lajsd lkasjd lajsd lks';
var shortText = 'if (a < b && c > d) {} // Héllö naõ';
function safe_tags_regex(str) {
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
}
function safe_tags_dom(str) {
var div = document.createElement('div');
div.appendChild(document.createTextNode(str));
return div.innerHTML;
}
function safe_tags_dom2(str) {
var div = document.createElement('div');
div.innerText = str;
return div.innerHTML;
}
var tagsToReplace = {
'&': '&',
'<': '<',
'>': '>'
};
function replaceTag(tag) {
return tagsToReplace[tag] || tag;
}
function safe_tags_replace(str) {
return str.replace(/[&<>]/g, replaceTag);
}
function safe_tags_replace_inlinevars(str) {
return str.replace(/[&<>]/g, function(t) {
return ({
'&': '&',
'<': '<',
'>': '>'
})[t] || t
});
}
var safe_tags_replace_cachevars = (function() {
var r = /[&<>]/g,
ts = { '&': '&', '<': '<', '>': '>' },
f = function(t) { return ts[t] || t };
return function(str) { return str.replace(r, f) }
})();
function save_tags_jquerytmpl(text) {
return (text + "").split("<").join("<").split(">").join(">").split('"').join(""").split("'").join("'");
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Using Regular Expression |
| ready |
Using DOM textNode |
| ready |
Using replace |
| ready |
Using DOM innerText |
| ready |
Using replace (inline vars) |
| ready |
Using replace (cached vars) |
| ready |
jquerytmpl |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.