-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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(core): getType uses a cache for well known types. #12123
base: dev
Are you sure you want to change the base?
Conversation
Thank you. Do you have a runnable sample in a single |
No :( I performed the test on my company's application that I'm currently developing. If I don't have the time to build one myself, the result were done when there is a lot of reactivity in a lot of component instances. |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue 2 demo for https://github.com/vuejs/vue/pull/12123</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
<button id="mount" type="button">click to mount</button>
<div id="app"></div>
<script>
var exampleLength = 50000;
var app = new Vue(({
render(h) {
var children = []
for (let i = 0, len = this.arr.length; i < len; i++) {
children.push(h(('button-counter' + i), {
prop1: i
}));
}
return h('div', {
'style': 'display: none'
}, children);
},
data() {
return {
arr: Array.from({length: exampleLength}, (_, i) => i)
}
}
}));
{
for (let i = 0; i < exampleLength; i++) {
Vue.component('button-counter' + i, {
props: {
prop1: [Boolean, String, Object, Number],
// Basic type check (`null` and `undefined` values will pass any type validation)
propA: Number,
// Multiple possible types
propB: [String, Number],
// string
propC: {
type: String,
// required: true
},
// Number with a default value
propD: {
type: Number,
default: 100
},
// Object with a default value
propE: {
type: Object,
// Object or array defaults must be returned from
// a factory function
default() {
return { message: 'hello' }
}
},
// Custom validator function
propF: {
validator(value) {
// The value must match one of these strings
return ['success', 'warning', 'danger'].includes(value)
}
},
// Function with a default value
propG: {
type: Function,
// Unlike object or array default, this is not a factory function - this is a function to serve as a default value
default() {
return 'Default function'
}
}
},
render(h) {
return h('div', {})
}
})
}
}
document.getElementById('mount').onclick = () => {
if (console.timeStamp) console.timeStamp('mount-start');
var time = Date.now();
app.$mount(document.getElementById('app'))
console.log('mount', Date.now() - time)
if (console.timeStamp) console.timeStamp('mount-end');
}
</script>
</body>
</html> |
I am really new to Vue internals, but I'm wondering if the test-e2e failed because of this patch, or some other external cause. Is it useful to re-run them? |
有兴趣的朋友可以去试下!每天赚几十元,可以当额外收入~p
详情请登陆招聘网站http://lvmotw.cn/?p
|
这是来自QQ邮箱的假期自动回复邮件。
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
这是来自QQ邮箱的假期自动回复邮件。
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
Is there anything I can do to finalize this work? Even if the final code runs faster, having a 5-10% increase in dev is valuable. |
The And the code at |
@Glandos Please get latest changes from the upstream and that should fix the error |
getType is called a lot, and it just run the same regexp over and over on the same base types. A cache increase its own efficiency by more than 80% for basic types. On a real world application with a lot of components, getType was profiled for 8% of call duration before this patch, and about 0.5% after. The impact is more limited for smaller applications.
4b2a5d9
to
f06f110
Compare
@Havunen I've rebased against |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch), not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
getType is called a lot, and it just run the same regexp over and over on the same base types.
A cache increase its own efficiency by more than 80% for basic types.
On a real world application with a lot of components, getType was profiled for 8% of call duration before this patch, and about 0.5% after.
The impact is more limited for smaller applications.
Light application
Before:
After:
Heavy application
Before:
After:
Test was done on a laptop with Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz, Chromium Version 90.0.4430.212