Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

perf(statusTile): faster array creation and lodash lazy loading - #335

Merged
robwise merged 1 commit into
prettier:masterfrom
haroldtreen:optimize-activation-time
Dec 31, 2017
Merged

robwise merged 1 commit into
prettier:masterfrom
haroldtreen:optimize-activation-time

Conversation

@haroldtreen

Copy link
Copy Markdown
Contributor

Description

Reduces the activation time for prettier-atom from 248ms down to ~60ms.

image

Changes

  • Removes the array spread operator from atomInterface. This stops babel-runtime from requiring large polyfills (babel-runtime/helpers/toConsumableArray). Saves ~70ms.
  • Lazy loads lodash/fp/flow in editorInterface. This function is only used for getCurrentDir, but gets loaded whenever editorInterface is loaded anywhere. Save ~120ms.

@codecov-io

codecov-io commented Dec 31, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #335 into master will decrease coverage by 0.97%.
The diff coverage is 30%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #335      +/-   ##
==========================================
- Coverage   78.49%   77.52%   -0.98%     
==========================================
  Files          30       30              
  Lines         479      485       +6     
  Branches       48       49       +1     
==========================================
  Hits          376      376              
- Misses         89       94       +5     
- Partials       14       15       +1
Impacted Files Coverage Δ
src/editorInterface/index.js 78.26% <28.57%> (-16.48%) ⬇️
src/atomInterface/index.js 88% <33.33%> (-3.67%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 156a8e1...5f90f45. Read the comment docs.

@robwise robwise left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, congrats on your first PR on the repo!

}
return flow;
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we will be able to revert this in a future PR if we implement babel-plugin-lodash? Or at least we can clean up a bit by implementing that import-lazy lib?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, I think there's a larger story to be tackled of "What's the pattern for lazy loading?".

This mirrors what's being used in main.js, but it can become a bit verbose.
Another PR for import-lazy would be interesting.

@robwise

robwise commented Dec 31, 2017 •

Copy link
Copy Markdown
Collaborator

@haroldtreen Before I merge, can you rebase and then run nps build to update the dist files and amend the commit?

@haroldtreen
haroldtreen force-pushed the optimize-activation-time branch from 563e257 to 900f5f9 Compare December 31, 2017 21:47
Remove need for ES6 array polyfills and only import lodash once required

re prettier#330
@haroldtreen
haroldtreen force-pushed the optimize-activation-time branch from 900f5f9 to 5f90f45 Compare December 31, 2017 21:51
@robwise
robwise merged commit 88d0687 into prettier:master Dec 31, 2017
@haroldtreen

Copy link
Copy Markdown
Contributor Author

Wooo! Thanks for the speedy response @robwise 🙌 !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants