Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hasOwnProperty to check for object properties #116

Merged
merged 1 commit into from
Mar 6, 2017

Conversation

lencioni
Copy link
Contributor

@lencioni lencioni commented Mar 6, 2017

I've been doing some performance profiling of Aphrodite and noticed that
even after updating to inline-style-prefixer 3.0.0, the prefixValue
function was still more expensive than I expected. After looking at the
CPU profile and the lines highlighted here, it seems that checking for
the existence of these object properties using foo[bar] is much more
expensive than checking using foo.hasOwnProperty(bar).

@lencioni
Copy link
Contributor Author

lencioni commented Mar 6, 2017

In my profiling of Aphrodite's css(), this PR plus #115 and robinweser/css-in-js-utils#1 dramatically improve the performance of prefixValue().

Before, 429ms (21.41% of total css() time):

screen shot 2017-03-05 at 9 42 26 pm

After, 75ms (6.36% of total css() time):

screen shot 2017-03-05 at 9 43 26 pm

It also brings down prefixProperty from ~55ms to ~11ms in my benchmark.

I've been doing some performance profiling of Aphrodite and noticed that
even after updating to inline-style-prefixer 3.0.0, the prefixValue
function was still more expensive than I expected. After looking at the
CPU profile and the lines highlighted here, it seems that checking for
the existence of these object properties using `foo[bar]` is much more
expensive than checking using `foo.hasOwnProperty(bar)`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants