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
results acquired via ajax requests need to be converted into lots of html. assuming we dont want to add node by node, the dom insertion can either be by creating a giant string, or by caching a detached dom element and cloning it.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="test" style="display:none"> </div>
<script>
function getFinalStr(arr, firstVal, restVal) {
var s = '';
for (var i = 0; i < arr.length; i++) {
s += arr[i] + (i < arr.length - 1 ? (i === 0 ? firstVal : restVal) : '');
}
return s;
}
var outerTemplateStr = ['<div class="innerClass">', '</div><div class="someClass3">', '</div><div class="someClass4">', '</div>'],
outerTemplateObj = $(outerTemplateStr.join('')),
innerTemplateStr = ['<div class="someInnerClass">', '</div><div class="someInnerClass">', '</div>'],
innerTemplateObj = $(innerTemplateStr.join('')),
testDiv = $('#test');
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
giant string concatention and innerHTML |
| ready |
append via clone |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.