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
Further checking into the performance of JS arrays - I am iterating each variable first just in case modern browsers optimise differently nested arrays.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
window.arrayCheck1 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
window.arrayCheck2 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t'];
window.arrayCheck3 = ['dasdadas', 'asdasdasd', 'asdwesad', 'vesdvsd', 'sdfsadfsdf', 'sdfsdfsdf', 'sdfsdfe'];
window.arrayCheck4 = [];
for (var i = 0; i < 100; i++) {
window.arrayCheck4.push(Math.floor(Math.random() * 100));
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
window.arrayCheck5 = [];
for (var i = 0; i < 100; i++) {
window.arrayCheck5.push(String.fromCharCode(getRandomInt(97, 122)));
}
Ready to run.
Test | Ops/sec | |
---|---|---|
jQuery iterate |
| ready |
For loop iterate |
| ready |
ForEach loop iterate |
| ready |
While loop iterate |
| ready |
Reverse while |
| ready |
For loop without length cache |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.