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

perf: more light-weight computed #452

Merged
merged 4 commits into from
Aug 6, 2020
Merged

perf: more light-weight computed #452

merged 4 commits into from
Aug 6, 2020

Conversation

shaonialife
Copy link
Contributor

No description provided.

@antfu
Copy link
Member

antfu commented Jul 27, 2020

Interesting, can you have a simple pref comparison on this? Thanks

@shaonialife
Copy link
Contributor Author

shaonialife commented Jul 27, 2020

相对于原来的实现, 现在的 computed 只用到一个 Watcher 对象, 而原来的用到了 Vue对象, 在初始化 Vue 实例时, 需要做很多额外的工作, 比如调用生命周期方法等, 而且内存占用相对更多. 相比较而言, 只用 Watcher 对象要轻量得多, 我在项目中已经这样用了一个月多了, 没有发现什么奇怪的问题

@antfu
Copy link
Member

antfu commented Aug 5, 2020

@shaonialife This PR looks promising and I would love to have this improvement, but before getting this merged, we should have a pref test/benchmarking to show the difference. I can do that when I got some time. Or if you would like to try, please feel free to do so. Thanks!

@antfu antfu self-assigned this Aug 5, 2020
@shaonialife
Copy link
Contributor Author

shaonialife commented Aug 6, 2020

@antfu 仅仅是一个内存占用测试, 没有测试其他项目😊 https://github.com/shaonialife/vue-computed-mem-test

@antfu
Copy link
Member

antfu commented Aug 6, 2020

@shaonialife Wow, that's a huge improvement, thanks for your work :)

The code looks good to me, /cc @pikax what do you think?

Copy link
Member

@pikax pikax left a comment

Choose a reason for hiding this comment

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

Also good to me!

Thank you 🚀

@antfu antfu merged commit 95d87f1 into vuejs:master Aug 6, 2020
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

3 participants