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
Fastest method for looping through an array of 1024 items and do a minimal operation with the new value each time.
http://jsfiddle.net/molokoloco/qeWhB/
In this new test, array is regenerated for each bentchmark because of destructive methods and how jperf perform the test (cf. https://twitter.com/molokoloco/status/443013019548020736)
<script src="//code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>
// Get a new copy of the array each time
var getArray = (function() {
var arr = [];
for (var i = 0; i < 1024; i++) arr[i] = i;
return function() {
return arr.slice();
};
}());
// Fake function with minimal action on the value
var process = function(value) {
return value + 1;
};
Ready to run.
Test | Ops/sec | |
---|---|---|
for() |
| ready |
for() caching |
| ready |
for() decrement |
| ready |
for (..in) |
| ready |
for (..pop()) - reverse order |
| ready |
for (..shift()) - keep order |
| ready |
for (..shift()) - keep order + copy |
| ready |
while() acting like for() |
| ready |
while() caching |
| ready |
while() in decrement |
| ready |
while(..pop()) |
| ready |
do while() |
| ready |
forEach() |
| ready |
map() |
| ready |
$.each() |
| ready |
_.each() |
| ready |
Generator (JS 1.7) |
| ready |
Only Populate |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.