alias vs dot lookup speed

JavaScript performance comparison

Test case created by hunterloftis

Info

http://stackoverflow.com/questions/14178807/is-it-advisable-to-cache-objects-that-are-only-used-twice-in-javascript/14178867#14178867

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var app = {
      user: {
        name: 'Hunter Loftis',
        url: 'hunterloftis.com'
      }
    };
};
</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
alias
var user = app.user;
var name = user.name;
var url = user.url;
pending…
dot
var name = app.user.name;
var url = app.user.url;
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

Add a comment