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
Compare the performance between the following iterating mechanisms: Array.forEach, for loop (forward and reverse), while loop (forward and reverse), lodash library (_.each and _.eachRight)
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
// Initialize the base array
var arr = [];
for (var i = 0; i < 500; i++) {
arr[i] = i;
}
var len = arr.length;
// The function to be called on each iteration
var iterateFunc = function(item, index) {
return index + item * 3 * 8;
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Array.forEach |
| ready |
Regular for loop |
| ready |
Funky for loop |
| ready |
While loop (internally used by lodash _.each) |
| ready |
lodash _.each |
| ready |
Reverse regular for loop |
| ready |
Reverse funky for loop |
| ready |
Reverse while loop (internally used by lodash _.eachRight) |
| ready |
lodash _.eachRight |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.