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
Dojo (1.7.3) array.forEach vs native for loop
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.7.3/dojo/dojo.js">
</script>
<script>
// setup `arr` array ('small')
var arr = ['1', true, false, "", void 0, null, 2, 18.5936];
// testing for having deleted keys in array
delete(arr[3]);
// seed `arr_keys` hash
var arr_keys = {};
for (var i = 0; i < arr.length; i++) {
arr.hasOwnProperty(i) && (arr_keys[i] = 0);
}
// setup `arr2` array ('medium')
var arr2 = arr.slice(0);
for (var j = 0; j < 500; j++) {
arr2.push(Math.round(Math.random()));
}
// seed `arr2_keys` hash
var arr2_keys = {};
for (j = 0; j < arr2.length; j++) {
arr2.hasOwnProperty(j) && (arr2_keys[j] = 0);
}
// setup `arr3` array ('big')
var arr3 = arr2.slice(0);
for (var m = 0; m < 5000; m++) {
arr3.push(Math.round(Math.random()));
}
// seed `arr3_keys` hash
var arr3_keys = {};
for (m = 0; m < arr3.length; m++) {
arr3.hasOwnProperty(m) && (arr3_keys[m] = 0);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
for-loop (small array) |
| ready |
Dojo array.forEach (small array) |
| ready |
for-loop (big array) |
| ready |
Dojo array.forEach (big array) |
| ready |
jQuery.each (small array) |
| ready |
jQuery.each (big array) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.