closure-no-closure-

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function createClosure() {
      var a = 'hi';
   
      return function() {
        alert(a);
      };
    }
   
    function createNonClosure() {
      return function() {
        alert('hi');
      };
    }
   
    var static = createClosure();
   
    var a = [],
        b = [],
        c = [];
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
closure
var a = createClosure()
pending…
nonclosure
var a = createNonClosure();
pending…
static
var a = static;
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:

1 comment

Jesse Decker commented :

This test is flawed: the last test performs variable assignment ONLY. No tests contain a common function call for reference and to test variable chain lookups. Updated in v2.

Add a comment