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="foo">
<h6>Element</h6>
<div class="bar">Class</div>
<div id="bar">Sub-ID</div>
<input type="text" value="FooBar">
<span id="hidden" style="display:none;">Hidden</span>
<ul id="ul" class="ul">
<li class="li">One</li>
<li class="li">Two</li>
<li class="li">Three</li>
<li class="li">Four</li>
<li class="li">Five</li>
<li class="li">Six</li>
</ul>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
var testObj;
var d = document;
(function($){
testObj = {
testObj:function ( test ) {
switch(test){
case 1:return $('div');
case 2:return d.getElementsByTagName('div');
case 3:return d.querySelectorAll('div');
case 4:return $('.li');
case 5:return d.getElementsByClassName('li');
case 6:return d.querySelectorAll('.li');
case 7:return $('#foo');
case 8:return d.getElementById('foo');
case 9:return d.querySelector('#foo');
case 10:return $('#foo').find('span');
case 11:return $('span', '#foo');
case 12:return d.getElementById('foo').getElementsClassNameId('span');
case 13:return d.querySelector('#foo .span');
case 14:return $('span#hidden');
case 15:return d.querySelector('span#foo');
case 16:return $('ul.ul');
case 17:return d.querySelector('ul.ul');
case 18:return $('ul#ul');
case 19:return d.querySelector('ul#ul');
default: break;
}
}
};
})(jQuery);
Ready to run.
Test | Ops/sec | |
---|---|---|
getElementById('foo'); |
| ready |
querySelectorAll('.li'); |
| ready |
querySelector('#foo'); |
| ready |
querySelectorAll('div'); |
| ready |
$('#foo'); |
| ready |
$('span#hidden'); |
| ready |
$('.li'); |
| ready |
$('div'); |
| ready |
$('ul#ul'); |
| ready |
querySelector('#foo .span'); |
| ready |
querySelector('span#foo'); |
| ready |
$('ul.ul'); |
| ready |
getElementById('foo').getElementsClassNameId('span'); |
| ready |
getElementsByClassName('li'); |
| ready |
$('#foo').find('span'); |
| ready |
getElementsByTagName('div'); |
| ready |
$('span', '#foo'); |
| ready |
querySelector('ul#ul'); |
| ready |
querySelector('ul.ul'); |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.