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

[Addon: Knobs] - Performance Fix: added debouncing between keystrokes to speed up component rendering #5811

Merged

Conversation

CodeByAlex
Copy link
Member

@CodeByAlex CodeByAlex commented Mar 1, 2019

Issue: #5376

What I did

I added debouncing logic with lodash within the knob changed function to reduce the number of times a component is rendered when the user is typing. The knob changed functionality will only be called if there is a delay of 150ms(slightly faster than the average time between keypress) during user typing. The previous version re-rendered the component upon each keypress. This will help increase performance and is seen mostly when running large components within storybook.

For more information about this PR, please refer to #5376

How to test

  • Is this testable with Jest or Chromatic screenshots? No
  • Does this need a new example in the kitchen sink apps? No
  • Does this need an update to the documentation? No

@vercel
Copy link

vercel bot commented Mar 1, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

@vercel vercel bot requested a deployment to staging March 1, 2019 16:19 Abandoned
@vercel
Copy link

vercel bot commented Mar 1, 2019

You are pushing commits at a very fast pace (accross the whole organization).
Due to that, we cannot deploy the commit 429752a.

You can try again later or upgrade your plan.

@CodeByAlex CodeByAlex changed the title added debouncing at 155ms between each keypress before the forceReRender function is called Performance Fix: added debouncing at 155ms between each keypress before the forceReRender function is called Mar 1, 2019
@codecov
Copy link

codecov bot commented Mar 2, 2019

Codecov Report

Merging #5811 into next will decrease coverage by 0.99%.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff            @@
##             next    #5811    +/-   ##
========================================
- Coverage   34.97%   33.98%    -1%     
========================================
  Files         648      651     +3     
  Lines        9480     9477     -3     
  Branches     1360     1345    -15     
========================================
- Hits         3316     3221    -95     
- Misses       5534     5641   +107     
+ Partials      630      615    -15
Impacted Files Coverage Δ
addons/knobs/src/registerKnobs.js 0% <0%> (ø) ⬆️
lib/theming/src/themes/dark.ts 0% <0%> (-100%) ⬇️
addons/notes/src/shared.ts 0% <0%> (-100%) ⬇️
lib/theming/src/animation.ts 0% <0%> (-100%) ⬇️
lib/theming/src/utils.ts 0% <0%> (-100%) ⬇️
lib/theming/src/themes/light.ts 0% <0%> (-100%) ⬇️
lib/theming/src/modules/syntax.ts 0% <0%> (-100%) ⬇️
lib/theming/src/base.ts 0% <0%> (-100%) ⬇️
lib/theming/src/create.ts 0% <0%> (-89.59%) ⬇️
lib/ui/src/libs/merge.js 36.36% <0%> (-45.46%) ⬇️
... and 24 more

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 10cb244...ca63d0e. Read the comment docs.

@CodeByAlex CodeByAlex changed the title Performance Fix: added debouncing at 155ms between each keypress before the forceReRender function is called [Addon: Knobs] - Performance Fix: added debouncing between keystrokes to speed up component rendering Mar 5, 2019
@shilman shilman added this to the v5.1.0 milestone Mar 6, 2019
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

LGTM?

@shilman
Copy link
Member

shilman commented Mar 6, 2019

cc @ndelangen @tmeasday

@tmeasday
Copy link
Member

tmeasday commented Mar 7, 2019

This seems good, although I wonder if we should use debounce from lodash instead of the handrolled setTimeout method?

@CodeByAlex
Copy link
Member Author

Good idea @tmeasday . I agree since Lodash is tried and true and is already being used in the project where debouncing occurs. I've pushed to the branch and updated the PR. Mind taking another look?

@shilman shilman added the bug label Mar 7, 2019
Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

LGTM!

@shilman shilman merged commit 927eaab into storybookjs:next Mar 7, 2019
@shilman shilman modified the milestones: v5.1.0, 5.0.x Mar 7, 2019
@shilman shilman added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Mar 7, 2019
@shilman shilman added the patch:done Patch/release PRs already cherry-picked to main/release branch label Mar 8, 2019
shilman added a commit that referenced this pull request Mar 8, 2019
…debouncing

[Addon: Knobs] - Performance Fix: added debouncing between keystrokes to speed up component rendering
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: knobs bug patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch performance issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants