Nested Named Functions compared to Module Pattern without last module pattern (v24)

Revision 24 of this benchmark created by max jooher on


Description

Investigating the performance hit caused by nested functions.

Setup

var Closure = (function() {
    
      var store;
    
      function inner(a) {
        store = a;
      };
    
      return {
    
        Nested: function(a) {
          function inner(a) {
            store = a;
          };
          inner(a);
        },
    
        Unnested: function(a) {
          inner(a)
        }
      }
    })();
    
    
    var flat;
    
    function Nested(a) {
      function inner(a) {
        flat = a;
      };
      inner(a);
    };
    
    function Unnested(a) {
      inner(a);
    }
    
    function inner(a) {
      flat = a;
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Nested inside Closure
Closure.Nested(1);
ready
Unnested inside Closure
Closure.Unnested(1);
ready
Nested
Nested(1);
ready
Unnested
Unnested(1);
ready

Revisions

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