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
Tests
Using a string with a size of 100k <div>x</div>
s, wrapped in a <body>
element.
The last two methods involve creating an offline document (contrary to the firsy method, external resources such as <img>
are not loaded).
No error checking is added. When this test case was created, Firefox (12+) was the only browser which supported all of the three methods. The first and second test should pass on all modern browsers though (the first on ancient browsers as well!).
var testString = '<body>' + Array(100001).join('<div>x</div>') + '</body>';
function test_innerHTML() {
var b = document.createElement('body');
b.innerHTML = testString;
return b;
}
function test_createHTMLDocument() {
var d = document.implementation.createHTMLDocument('');
d.body.innerHTML = testString;
return d.body;
}
function test_DOMParser() {
return (new DOMParser()).parseFromString(testString, 'text/html').body;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
body+innerHTML |
| ready |
createHTMLDocument |
| ready |
DOMParser+text/html |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.