Array Max

JavaScript performance comparison

Test case created by Chris Barna

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var numbers = [15, 36, 27, 42, 80, 13];
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
for loop
var largest = 0;
for (i = 0; i < numbers.length; i++) {
  if (numbers[i] > largest) {
    largest = numbers[i];
  }
}
pending…
apply()
Math.max.apply(Math, numbers);
pending…
Native
Math.max(15, 36, 27, 42, 80, 13);
pending…

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

Compare results of other browsers

0 comments

Add a comment