variable vs property lookup

JavaScript performance comparison

Test case created by Joshua Piccari

Info

Testing the lookup speed of cached variables vs un-cached object properties.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var hugeArray = Array.apply(0, Array(10000)),
        lengthOfHugeArray = hugeArray.length;
};
</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
Cached variable
lengthOfHugeArray;
pending…
Un-cached property
hugeArray.length;
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