performance testing of named or anonymous functions (v44)

Revision 44 of this benchmark created by John on


Description

a small comparision betwean named function and function declaration

Setup

var power = 10;
    
    var expressionFunction = function(base) {
      return Math.pow(base, power);
    };
    
    function declaredFunction(base) {
      return Math.pow(base, power);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
anonymous
for (var i = 0; i < 10000; ++i) {
  var myEventHandler = function(base) {
    return Math.pow(base, 10);
  };

  var x = myEventHandler(i);
}
ready
function expression
for (var i = 0; i < 10000; ++i) {
  var x = expressionFunction(i);
}
ready
function declaration


for (var i = 0; i < 10000; ++i) {
  var x = declaredFunction(i);
}
ready

Revisions

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