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 textarea = document.createElement('textarea');
function safe_tags_regex(str) {
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
}
function safe_tags_dom(str) {
textarea.innerHTML = str;
return textarea.innerHTML;
}
var tagsToReplace = {
'&': '&',
'<': '<',
'>': '>'
};
function replaceTag(tag) {
return tagsToReplace[tag] || tag;
}
function safe_tags_replace(str) {
return str.replace(/[&<>]/g, replaceTag);
}
function safe_tags_split(str) {
return str
.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 split & join |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.