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
This will test the performance between using a hand written recursive function that uses .children vs jquery's native context selector.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
</script>
<script type="text/javascript">
function addCSSClassRecursively(topElement, CssClass) {
$(topElement).addClass(CssClass);
$(topElement).children().each(
function() {
addCSSClassRecursively($(this), CssClass);
});
}
</script>
<div id="parent">
<div>
<div>
<div>
<div>
<div>
<div>
</div>
</div>
</div>
</div>
<div>
</div>
</div>
<div>
</div>
</div>
<div>
</div>
</div>
Ready to run.
Test | Ops/sec | |
---|---|---|
jquery context selector |
| ready |
recursion method |
| ready |
Decendant |
| ready |
modified context selector |
| ready |
Decendant little mod |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.