Scope depth and execution speed

Benchmark created by Anton Bulyonov on


Setup

function addOne1(a) {
      var b = 1;
      return function() {
        return a + b;
      };
    }
    
    function addOne10(a) {
      var b = 1;
      return function() {
        return function() {
          return function() {
            return function() {
              return function() {
                return function() {
                  return function() {
                    return function() {
                      return function() {
                        return function() {
                          return a + b;
                        };
                      };
                    };
                  };
                };
              };
            };
          };
        };
      };
    }

Test runner

Ready to run.

Testing in
TestOps/sec
One parent scope
addOne1(Math.random());
ready
Ten parent scopes
addOne10(Math.random());
ready

Revisions

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

  • Revision 1: published by Anton Bulyonov on