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
Comparing methods for looping through an array of 100000 items and do a minimal operation with the new value each time.
In this new test, array is not regenerated for each benchmarks because of destructive methods (cf. https://twitter.com/molokoloco/status/443013019548020736) You can compare .pop() / .shift() between themselves, acknowledging they also copy the array for each test...
This big broken test, for the use of only one array and some destructive methods... (all the tests after shift() or pop() run with an empty array)
Thanks you peoples of JS ;)
an<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>
// Fake function with minimal action on the value
var tmp = 0;
var process = function(value) {
tmp = value; // Old a ref to the variable (prevent engine optim?)
};
// Declare the test Array
var arr = [];
for (var i = 0; i < 100000; i++) arr[i] = i + 0.5;
var arrBuf = new Float32Array(100000);
for (var i = 0; i < 100000; i++) arrBuf[i] = i + 0.5;
Ready to run.
Test | Ops/sec | |
---|---|---|
for() |
| ready |
for() caching |
| ready |
for() arrBuf |
| ready |
for() caching arrBuf |
| ready |
_.each() |
| ready |
_.each() arrBuf |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.