max

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    grades = [6, 1, 35, 135, 2, 52];
    grades2 = [2, 54, 3535, 34, 34, 5, 1, 6, 23, 36, 1, 5, 2, 6,1 1, 5, 1535];
   
    function one(grades) {
     return Math.max.apply(null, grades);
    }
   
    function two(grades) {
     return grades.sort(function(a, b) { return b - a } )[0];
    }
};
</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
Math
one(grades);
 
pending…
Sort
two(grades);
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