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 src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<pre id="text" style="height : 200px;">
</pre>
var ele = document.getElementById("text");
var tenElsStr = "<b>1</b><i>2</i><b>3</b><i>4</i><b>5</b><i>6</i><b>7</b><i>8</i><b>9</b><i> </i>";
function multiply (str, num) {
return Array(num + 1).join(str);
}
// This is much faster than simple use of innerHTML in some browsers
// See <http://blog.stevenlevithan.com/archives/faster-than-innerhtml>
function replaceHtml(el, html) {
var oldEl = el;
/*@cc_on // Pure innerHTML is slightly faster in IE
oldEl.innerHTML = html;
return oldEl;
@*/
var newEl = oldEl.cloneNode(false);
newEl.innerHTML = html;
oldEl.parentNode.replaceChild(newEl, oldEl);
/* Since we just removed the old element from the DOM, return a reference
to the new element, which can be used to restore variable references. */
return newEl;
}
var testStr = multiply(tenElsStr, 1000);
var $ele = $(ele);
Ready to run.
Test | Ops/sec | |
---|---|---|
.innerHTML |
| ready |
replaceHtml |
| ready |
$.html |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.