atom / deprecation-cop

Shows a list of deprecated calls
MIT License
12 stars 19 forks source link

Optimization of an initial update of the status bar view #58

Closed kubetz closed 7 years ago

kubetz commented 9 years ago

My try to help with the performance of deprecation-cop.

Disclaimer: I am an atom newbie and coffeescript one too for that matter, so I am very open for any feedback, best practices, lessons, etc. :innocent: .

I have noticed that status-bar activation times are rather high and found out that a lot of the time is used by deprecation-cop package. Helper functions seems to be the main bottleneck of the performance here. @ypresto did already a great job by minimizing calls to the helper functions using _.debounce.

What is still taking a solid amount of time is the initial @update of the DeprecationCopStatusBarView when the view is attached as it is not using debouncedUpdateDeprecatedSelectorCount function available in the view.

Here is a screenshot showing a performance impact of an immediate @update() (using performance.now() for measuring the time): 1_attach_update

Here is a screenshot after using debouncedUpdateDeprecatedSelectorCount() instead of update(): 2_attach_debounce

The downside of not using immediate @update() is that the initial information is communicated to the user later, of course. I had to hide the view during initialization because of this reason to prevent showing the initial 0 deprecations for 1s until the @update was called and the view was hidden.

I added some comments to the source code.

as-cii commented 7 years ago

Thanks for the pull request, @kubetz, and sorry for the late reply!

Getting the deprecated selectors count should now be negligible, as it delegates to atom.styles.getDeprecations, which internally consults an in-memory object, so I am going to close this pull request. Thanks again!