-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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: Use @@toStringTag and Map for better perf #12491
base: main
Are you sure you want to change the base?
Conversation
…her than object to be faster and more accurate
|
@Justineo Thanks. I hardly use Use |
You could consider setting up some benchmarks on platforms like jsbench.me. |
Here is my benchmark example: https://jsbench.me/krm45pp7nd/1 And here is the result:
Looks good. And here is benchmark comparation result, I only picked the result that is changed larger than 5% and rme is less than 1%: I do not know which part is important, but it looks good to me, especially there are 3 cases that improves 20%+
|
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/runtime-core
@vue/reactivity
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
I got different performance data, see https://measurethat.net/Benchmarks/Show/32894/1/test-map-vs-object |
here is my 5 cents about benchmark: For set-value, the perf is similar, for get-value, Map is 200% faster(wow...) as shown in this case. If for the cache in Vue, the key is more frequently to be different with the key last time visited, then this test case might reflect real world better. |
LGTM |
…Tian/vue3 into macro-optimization-shared
There are 2 macro optimizations:
instanceof
rather thantoString
, this is about 100% faster, and makes things more accurate.Map
rather thanObject
, this is about 30% faster.However, I am not sure about
isPromise
. According to the name, it only want to judge whether it's a Promise or not. But current logic is to judge whether it's thennable. This might be a breaking change.