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 = [];
function getRandomNumber() {
'use strict';
return Math.floor(Math.random() * 3000);
}
for (var i = 0; i < 3000; i++) {
ar.push(getRandomNumber());
}
var arSmall = ar.slice(0, 40);
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 Big |
| ready |
While Loop Big |
| ready |
indexOf Big |
| ready |
For Loop Small |
| ready |
While Loop Small |
| ready |
indexOf Small |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.