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
is obj.length === +obj.length fast?
<script>
var ary = [];
for(var i=0;i<10000;i++){
ary.push(i);
}
function comp1(obj){
if (obj.length === +obj.length){
return true;
}
}
function comp2(obj){
if (typeof obj.length==='number'){
return true;
}
}
function doComp1(){
comp1(ary);
comp1({});
}
function doComp2(){
comp2(ary);
comp2({});
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
+length |
| ready |
typeof |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.