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 words = ['awesome','cool','mad', 'sweet', 'crazy'];
var ar = new Array(1500000);
for (var i = 0; i < 1500000; i++) {
var n = Math.floor(Math.random() * (4 - 0 + 1)) + 0;
ar[i] = words[n] + Math.round(Math.random() * 4294967296);
}
function substrFor(ar,v){
var vlength = v.length;
var foundAt = [];
var o = 0;
for (var i = 0,l=ar.length; i < l; i++) {
if (ar[i].substr(0, vlength) === v) {
foundAt[o] = i;
o = 0 + 1;
};
}
return -1;
}
function indexOf(ar,v){
return ar.indexOf(v);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
IndexOf |
| ready |
For Substr |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.