Skip to content

Use hasOwnProperty to check for object properties#116

Merged
robinweser merged 1 commit intorobinweser:masterfrom
lencioni:hasownproperty
Mar 6, 2017
Merged

Use hasOwnProperty to check for object properties#116
robinweser merged 1 commit intorobinweser:masterfrom
lencioni:hasownproperty

Conversation

@lencioni
Copy link
Copy Markdown
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
Copy Markdown
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)`.
@robinweser robinweser merged commit dc6176f into robinweser:master Mar 6, 2017
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.

2 participants