Bug 133924 - Bracket access is significantly slower than property access
Summary: Bracket access is significantly slower than property access
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-14 23:05 PDT by Ryosuke Niwa
Modified: 2014-06-14 23:23 PDT (History)
5 users (show)

See Also:


Attachments
Microbenchmark (1.03 KB, text/html)
2014-06-14 23:05 PDT, Ryosuke Niwa
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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*