own each class test
JavaScript performance comparison
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.
| Test | Ops/sec | |
|---|---|---|
array each |
|
pending… |
my each |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments