Fastest Array min max (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script>
  function randomArray(count) {
   var array = [];
   for (i = 0; i < count; i++) {
    array.push(Math.floor(Math.random() * 1000000));
   }
   return array;
  }
  
  function custom_min(array) {
   var min_value = array[0];
   for (var i = 1, l = array.length; i < l; i++) {
    if (array[i] < min_value) {
     min_value = array[i];
    }
   }
   return min_value;
  }
  
  var ten = randomArray(10);
  var hundred = randomArray(100);
  var ten_thousand = randomArray(10000);
  var million = randomArray(1000000);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Math.min.apply - 100
Math.min.apply(Math, hundred);
ready
Custom - 100
custom_min(hundred);
ready
Math.min.apply - 10,000
Math.min.apply(Math, ten_thousand);
ready
Custom - 10,000
custom_min(ten_thousand);
ready
Math.min.apply - 1,000,000
Math.min.apply(Math, million);
ready
Custom - 1,000,000
custom_min(million);
ready
Math.min.apply - 10
Math.min.apply(Math, ten);
ready
Custom - 10
custom_min(ten);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.