closure vs name function in a loop (v7)

Revision 7 of this benchmark created by Derek on


Description

Testing the performance of calling a closure function in a loop and calling a defined (named) function in a loop.

Setup

function named(i){
      globalI += i;
    }
    var globalI = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
closure
var i;
for(i = 0 ; i < 100 ; i++) {
   //create and call closure function
   (function(i){
       globalI += i;
   })(i);
}
console.log(globalI);
ready
named
var i;
for(i = 0 ; i < 100 ; i++) {
  named(i);
}
console.log(globalI);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.