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
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
<script>
var ar = [];
for(z=0;z<500000;z++) {
ar.push(Math.floor(Math.random()*10000));
}
function indexOfFor(ar,v){
for (var i = 0,l=ar.length; i < l; i++) {
if (ar[i] === v) {
return i;
}
}
return -1;
}
function indexOfForIn(ar,v){
for (var i in ar) {
if (ar.hasOwnProperty(i) && (ar[i] === v)) {
return i;
}
}
return -1;
}
function indexOfWhile(ar,v){
var i=0,a;
while (a=ar[i++]) {
if (a === v) {
return i-1;
}
}
return -1;
}
function indexOf(ar,v){
return ar.indexOf(v);
}
function lodashIndexOf(ar,v){
return _.contains(ar,v);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
For loop |
| ready |
While Loop |
| ready |
indexOf |
| ready |
lodashIndexOf |
| ready |
For in |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.