own each class test

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function myArray(){
      this.data = [];
      for( var i = 0, e=arguments.length ; i<e; i++)
        this.data[i] = arguments[i];
    }
    myArray.prototype.each = function( fN ){
      for( var i = 0, e=this.data.length ; i<e; i++) fN( this.data[i] , i );
    }
   
    var sum = 0;
    function sumFN( el ){ sum += el; }
   
    var array = [1,2,3,4,5,6,7];
    var myArray = new myArray( 1,2,3,4,5,6,7);
};
</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
array each
array.forEach( sumFN );
pending…
my each
myArray.each( sumFN );
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