Nested Named Functions

Benchmark created by Jeremy McPeak (Nettuts) on


Description

Demonstrating the performance hit caused by nested functions.

Preparation HTML

<script>
  function foo(a, b) {
    function bar() {
      return a + b;
    }
  
    return bar();
  }
  
  function foo2(a, b) {
    return bar2(a, b);
  }
  
  function bar2(a, b) {
    return a + b;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Optimized (No Nesting)
foo2();
ready
Nested Function
foo();
ready

Revisions

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