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="testid"></div>
<div class="testclass"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script>
var regex = /[=#@.*]/g;
function newQuerySelectorAll (querySelector){
var matches = querySelector.match(regex),
selection, firstChar, tempElm;
if(matches.length > 0){
if(matches.length > 1){
selection = document.querySelectorAll(querySelector)
} else{
firstChar = querySelector.charAt(0);
if(firstChar === "."){
selection = document.getElementsByClassName(querySelector.slice(1))
} else if(firstChar === "#"){
//getElementById doesn't return an HTMLCollection, therefore we have to jump through some hoops to make one.
var dummyElm = document.createElement("div");
if(tempElm = document.getElementById(querySelector.slice(1)))
dummyElm.appendChild(tempElm);
selection = dummyElm.children;
} else{
selection = document.querySelectorAll(querySelector)
}
}
} else{
selection = document.getElementsByTagName(querySelector);
}
return selection;
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
jQuery ID Selector |
| ready |
getElementById |
| ready |
jQuery class Selector |
| ready |
Native querySelector |
| ready |
Create jQuery from Native |
| ready |
Native querySelector to jQuery Object |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.