Global Lookup: with 'self', 'window', and neither

JavaScript performance comparison

Test case created by Chris M. Balz

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  self.oTest = {
      sX: "Soufflé donut ice cream. Dragée danish jelly beans cotton candy oat cake. Candy canes caramels tiramisu bear claw muffin icing. Marshmallow jujubes faworki dessert. Bear claw chocolate cake chocolate cake brownie sesame snaps brownie faworki. Jelly-o gummi bears fruitcake cotton candy marshmallow jujubes cookie. Pie toffee tart tootsie roll bonbon cake. Halvah sweet pastry cookie croissant chupa chups candy canes. Chocolate jelly chocolate bar caramels applicake cotton candy caramels donut. Toffee jelly-o brownie pie bonbon gummies marshmallow topping. Toffee chupa chups sesame snaps caramels tootsie roll bear claw faworki macaroon chocolate. Jelly beans chupa chups caramels pudding wypas oat cake chocolate cake."
  };

};

Benchmark.prototype.teardown = function() {
  self.oTest = undefined;

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Prefixed with 'self'
(function lookup_test_1() {
    var sX = "x";

    self.oTest.sX += ".";

})();
pending…
Prefixed with 'window'
(function lookup_test_2() {
    var sX = "x";

    window.oTest.sX += ".";

})();
pending…
Not prefixed
(function lookup_test_3() {
    var sX = "x";

    oTest.sX += ".";

})();
pending…
Prefixed with 'self' and double-nested
(function lookup_test_4() {
    var sX = "x";

    (function inner(){
        var sX = "y";

        self.oTest.sX += ".";
    })();

})();
pending…
Prefixed with 'window' and double-nested
(function lookup_test_5() {
    var sX = "x";

    (function inner(){
        var sX = "y";

        window.oTest.sX += ".";
    })();

})();
pending…
Not prefixed and double-nested
(function lookup_test_6() {
    var sX = "x";

    (function inner(){
        var sX = "y";

        oTest.sX += ".";
     })();

})();
pending…

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

Compare results of other browsers

0 Comments