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
<div id="test">
</div>
const MAX=10;
function create(ofType, havingProperties, withParent) {
const elmt = document.createElement(ofType);
if (havingProperties) {
Object.entries(havingProperties).forEach(([key, value]) => {
if (key === 'classes') {
elmt.classList.add(...value);
} else {
elmt[key] = value;
}
});
}
if (withParent) {
withParent.appendChild(elmt);
}
return elmt;
}
class Dom {
constructor(tagName) {
/** @type {HTMLElement} */
this.elmt = document.createElement(tagName);
}
attr = function(name, value) {
this.elmt.setAttribute(name, value);
return this;
}
id(id) {
this.elmt.id = id;
return this;
}
text(text) {
this.elmt.textContent = text;
return this;
}
cls(...classes) {
this.elmt.classList.add(...classes);
return this;
}
onClick(listener) {
this.elmt.addEventListener('click', listener);
return this;
}
/**
* Appends the obj instances to the current DOM
* @param {Array<Dom>} children Object to append to current DOM instance
* @returns {Dom}
*/
append(...children) {
children.forEach((child) => {
this.elmt.appendChild(child.toHtml());
})
return this;
}
toHtml() {
return this.elmt;
}
}
document.getElementById('test'),innerHTML = '';
Ready to run.
Test | Ops/sec | |
---|---|---|
Method implementation |
| ready |
Vanilla implementation |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.