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 objEl = { '<>': 'test', '@href': 'blah', '+': [{ '<>': 'child', '@src': '/testing' },{ '<>': 'child', '@src': '/testing' },{ '<>': 'child', '@src': '/testing' },{ '<>': 'child', '@src': '/testing' },{ '<>': 'child', '@src': '/testing' }]};
var strEl = '<test href="blah"><child src="/testing" /><child src="/testing" /><child src="/testing" /><child src="/testing" /><child src="/testing" /></test>';
function parseObjEl(obj) {
if (obj.tagName) {
var el = document.createElement(obj['<>']);
for (var name in el) {
var value = obj[name];
if (name === '<>') { continue; }
if (name === '#') {
el.textContent = value;
continue;
}
if (name[0] === '@') {
el.setAttribute(name.substr(1), value);
continue;
}
if (name[0] === '+') {
for (var i = 0; i < value.length; i += 1) {
el.appendChild(parseObjEl(value[i]));
}
}
}
return el;
} else if (typeof obj === 'string') {
var tn = document.createTextNode(obj);
return tn;
}
}
var factory = document.createElement('div');
function parseStrEl(str) {
factory.innerHTML = str;
var ret = factory.firstChild;
factory.removeChild(ret);
return ret;
}
function parseStrElNoRemove(str) {
factory.innerHTML = str;
var ret = factory.firstChild;
return ret;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Object to DOM |
| ready |
String to DOM |
| ready |
String to DOM, no removeChild |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.