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>
var ar = new Array(1500000);
for (var i = 0; i < 1500000; i++) {
ar[i] = Math.round(Math.random() * 4294967296);
}
function indexOfFor(ar,v){
for (var i = 0,l=ar.length; i < l; i++) {
if (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);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
For loop |
| ready |
While Loop |
| ready |
indexOf |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.