Anonymous vs. Named Functions Callback

JavaScript performance comparison

Revision 2 of this test case created by Joshua Piccari

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Anonymous
function test(callback) {
   var x = 0;
   x++;
   callback(x);
}

test(function(x) {
   x--;
});
 
pending…
Declaration
function test(callback) {
   var x = 0;
   x++;
   callback(x);
}

function foo(x) {
   x--;
}

test(foo);
pending…
Stored expression
function test(callback) {
   var x = 0;
   x++;
   callback(x);
}

var foo = function(x) {
   x--;
};

test(foo);
pending…
Named, declared in lambda
function test(callback) {
   var x = 0;
   x++;
   callback(x);
}

test(function foo(x) {
   x--;
});
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