performance testing of named or anonymous functions (v19)

Revision 19 of this benchmark created by x3cion on


Description

a small comparision betwean named function and function declaration

Preparation HTML

<script>
a = 1;
x = [];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
anonymous
"use strict";
for (var i = 0; i < 10000; ++i) {
  x[a] = function() {a=a==1?a=0:a=1;};
  x[a]();
}
ready
function expression
"use strict";
myEventHandler = function() {
  a=a==1?a=0:a=1;
}

for (var i = 0; i < 10000; ++i) {
  x[a] = myEventHandler;
  x[a]();
}
ready
function declaration
"use strict";
function myEventHandler2() {
  a=a==1?a=0:a=1;
}

for (var i = 0; i < 10000; ++i) {
  x[a] = myEventHandler2;
  x[a]();
}
ready

Revisions

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