prototype chain lookup, cached or not

JavaScript performance comparison

Test case created by Kyle Simpson

Info

Testing/profiling the code patterns from the Script Junkie article "(pre)Maturely Optimize Your JavaScript"

http://msdn.microsoft.com/en-us/scriptjunkie/gg622887.aspx

Snippet comparison #5

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
full chain lookup
var foo = {
 fun: "weee!"
},
    bar = Object.create(foo),
    baz = Object.create(bar),
    _fun = baz.fun,
    res = "";

for (var i = 0; i < 1000; i++) {
 res += baz.fun[i % baz.fun.length]; // not using the cached scope lookup
}
pending…
cached chain lookup
var foo = {
 fun: "weee!"
},
    bar = Object.create(foo),
    baz = Object.create(bar),
    _fun = baz.fun,
    res = "";

for (var i = 0; i < 1000; i++) {
 res += _fun[i % _fun.length]; // not using the cached scope lookup
}
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