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
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
var testArray = [0, 10, 11, 9, 924, 19238, 1248, 8, 0, 0, 2, -1, -5];
var _getArrayMin = function(array) {
var min = Infinity;
_.each(array, function(val) {
if (min > val) {
min = val;
}
});
return min;
}
var $getArrayMin = function(array) {
var min = Infinity;
$.each(array, function(key, val) {
if (min > val) {
min = val;
}
});
return min;
}
var forGetArrayMin = function (array) {
var i = 0,
min = array[i++],
len = array.length,
val;
for (;i < len; i++) {
val = array[i];
if (min > val) {
min = val;
}
}
return min;
}
var whileGetArrayMin = function (array) {
var i = 0,
min = array[i++],
len = array.length,
val;
while (i < len) {
val = array[i++];
if (min > val) {
min = val;
}
}
return min;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
$.each |
| ready |
_.each |
| ready |
for |
| ready |
while |
| ready |
Using Math.min |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.