Bug 133924

Summary: Bracket access is significantly slower than property access
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Enhancement CC: barraclough, fpizlo, kling, mhahnenberg, mike
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Microbenchmark none

Description Ryosuke Niwa 2014-06-14 23:05:59 PDT
Created attachment 233135 [details]
Microbenchmark

function getByVal(object, property) {
    return object[property];
}

function getById(object) {
    return object.myProperty;
}

The first function appears to be ~3.5x slower than the second function even if getByVal is always called as getByVal(object, 'myProperty').

It's only 1.5x slower on Chrome 35 and 2.2x slower on Firefox 30.
Comment 1 Ryosuke Niwa 2014-06-14 23:07:14 PDT
Note that it's 3.7x slower in the shipping Safari so it has gotten better.
Comment 2 Ryosuke Niwa 2014-06-14 23:07:27 PDT
(In reply to comment #1)
> Note that it's 3.7x slower in the shipping Safari so it has gotten better.

4.7x*