closure lookup

JavaScript performance comparison

Revision 3 of this test case created by Jason Miller

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var a = new function() {
        var local = ['a', 'b'];
        return function(x) {
                return local[x];
        }
    }
   
    var b = function(x) {
        var local = ['a', 'b'];
        return local[x];
    }
   
    var local = ['a', 'b'];
    var c = function(x) {
        return local[x];
    }
};
</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
anonymous closure
a(1)
pending…
redefined array
b(1)
pending…
Stored Array
c(1)
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:

0 comments

Add a comment