native vs implmented - 0

JavaScript performance comparison

Revision 4 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function each (obj, func) {
        var kindex,
            length;
        for (kindex = 0, length = obj.length; kindex < length; kindex++) {
            func(obj[kindex],kindex,obj);
        }
    }
};
</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
implemented
each([0,1,2,3], function(val){
    val++;
});
pending…
native
[0,1,2,3].forEach(function(val){
    val++;
});
pending…
for
arr = [0,1,2,3];
for (var i = 0; i < arr.length; i++) {
  val = arr[i];
  val++;
}
pending…
for (enclosed)
arr = [0,1,2,3];
for (var i = 0; i < arr.length; i++) {
  (function(){
    val = arr[i];
    val++;
  }());
};
pending…
for (enclosed v2)
arr = [0,1,2,3];
var _fn = function(i) {
  val = arr[i];
  val++;
};
for (var i = 0; i < arr.length; i++) { _fn(i) };
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