test

JavaScript performance comparison

Revision 17 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var array = [1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3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,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1,2,3,4,5,9,2,4,1];
   
    function s1(array, callback){
                var i,
                        sum = 0
                ;
                       
                for(i = 0; i < array.length; i++){
                        if(array.hasOwnProperty(i)){
                                sum += callback ? callback.call(array[i], array[i], i, array) : array[i];
                        }
                }
               
                return sum;
        }
   
    function s2(array, callback){
                var i,
                        sum = 0
                ;
                       
   
    if(callback){
                for(i = 0; i < array.length; i++){
                        if(array.hasOwnProperty(i)){
                                sum += callback.call(array[i], array[i], i, array);
                        }
                }
    }else{
   
                for(i = 0; i < array.length; i++){
                        if(array.hasOwnProperty(i)){
                                sum += array[i];
                        }
                }
    }
               
                return sum;
        }
};
</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
1
s1(array);
pending…
2
s2(array);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment