Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Vue inner element vs inner component - 2
(version: 4)
Measure performance when parent containing component or element is changed
Comparing performance of:
With component vs With element vs With static value [component] vs With static value [element]
Created:
6 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/vue"></script> <div id="app"></div>
Tests:
With component
const name = Vue.component('str-component', { props: ['value'], render(createElement){ console.log(`Value: ${this.value} rendered`) return createElement("span", ['Value: ', this.value]); } }) new Vue({ el: "#app", data() { return { clickCount: 0, step: 0, width: 0, interval: undefined, maxSteps: 2, maxWidth: 100, minWidth: 0, dir: "increase", firstName: "Hello", lastName: "World" }; }, mounted() { this.interval = window.setInterval(this.benchmark, 10) }, methods: { onClick() { this.clickCount += 1; }, increaseWidth: function() { this.width = this.width + 1; }, decreaseWidth: function() { this.width = this.width - 1; }, benchmark: function() { if (this.step === this.maxSteps) { window.clearInterval(this.interval); return; } if (this.width === this.maxWidth) { this.dir = "decrease"; this.step++; } else if (this.width === this.minWidth) { this.dir = "increase"; } if (this.dir === "increase") { this.increaseWidth(); } else { this.decreaseWidth(); } } }, render(createElement) { const button = createElement( "button", { on: { click: this.onClick } }, "Click me" ); const counter = createElement("span", [ "Number of clicks:", this.clickCount ]); const firstName = createElement(name, {props: {value: this.firstName}}); if (this.width % 20 === 0){ console.log(`rendered ${this.width}`) } return createElement( "div", { style: { "background-color": "red", width: `${this.width}px` } }, [firstName] ); } });
With element
const name = Vue.component('str-component', { props: ['value'], render(createElement){ console.log(`Value: ${this.value} rendered`) return createElement("span", ['Value: ', this.value]); } }) new Vue({ el: "#app", data() { return { clickCount: 0, step: 0, width: 0, interval: undefined, maxSteps: 2, maxWidth: 100, minWidth: 0, dir: "increase", firstName: "Hello", lastName: "World" }; }, mounted() { this.interval = window.setInterval(this.benchmark, 10) }, methods: { onClick() { this.clickCount += 1; }, increaseWidth: function() { this.width = this.width + 1; }, decreaseWidth: function() { this.width = this.width - 1; }, benchmark: function() { if (this.step === this.maxSteps) { window.clearInterval(this.interval); return; } if (this.width === this.maxWidth) { this.dir = "decrease"; this.step++; } else if (this.width === this.minWidth) { this.dir = "increase"; } if (this.dir === "increase") { this.increaseWidth(); } else { this.decreaseWidth(); } } }, render(createElement) { const button = createElement( "button", { on: { click: this.onClick } }, "Click me" ); const counter = createElement("span", [ "Number of clicks:", this.clickCount ]); const firstName = createElement("span", ['Value: ', this.firstName]); if (this.width % 20 === 0){ console.log(`rendered ${this.width}`) } return createElement( "div", { style: { "background-color": "red", width: `${this.width}px` } }, [firstName] ); } });
With static value [component]
const name = Vue.component('str-component', { props: ['value'], render(createElement){ console.log(`Value: ${this.value} rendered`) return createElement("span", ['Value: ', this.value]); } }) new Vue({ el: "#app", data() { return { clickCount: 0, step: 0, width: 0, interval: undefined, maxSteps: 2, maxWidth: 100, minWidth: 0, dir: "increase", firstName: "Hello", lastName: "World" }; }, mounted() { this.interval = window.setInterval(this.benchmark, 10) }, methods: { onClick() { this.clickCount += 1; }, increaseWidth: function() { this.width = this.width + 1; }, decreaseWidth: function() { this.width = this.width - 1; }, benchmark: function() { if (this.step === this.maxSteps) { window.clearInterval(this.interval); return; } if (this.width === this.maxWidth) { this.dir = "decrease"; this.step++; } else if (this.width === this.minWidth) { this.dir = "increase"; } if (this.dir === "increase") { this.increaseWidth(); } else { this.decreaseWidth(); } } }, render(createElement) { const button = createElement( "button", { on: { click: this.onClick } }, "Click me" ); const counter = createElement("span", [ "Number of clicks:", this.clickCount ]); const firstName = createElement(name, {props: {value: 'Hello!'}}); if (this.width % 20 === 0){ console.log(`rendered ${this.width}`) } return createElement( "div", { style: { "background-color": "red", width: `${this.width}px` } }, [firstName] ); } });
With static value [element]
const name = Vue.component('str-component', { props: ['value'], render(createElement){ console.log(`Value: ${this.value} rendered`) return createElement("span", ['Value: ', this.value]); } }) new Vue({ el: "#app", data() { return { clickCount: 0, step: 0, width: 0, interval: undefined, maxSteps: 2, maxWidth: 100, minWidth: 0, dir: "increase", firstName: "Hello", lastName: "World" }; }, mounted() { this.interval = window.setInterval(this.benchmark, 10) }, methods: { onClick() { this.clickCount += 1; }, increaseWidth: function() { this.width = this.width + 1; }, decreaseWidth: function() { this.width = this.width - 1; }, benchmark: function() { if (this.step === this.maxSteps) { window.clearInterval(this.interval); return; } if (this.width === this.maxWidth) { this.dir = "decrease"; this.step++; } else if (this.width === this.minWidth) { this.dir = "increase"; } if (this.dir === "increase") { this.increaseWidth(); } else { this.decreaseWidth(); } } }, render(createElement) { const button = createElement( "button", { on: { click: this.onClick } }, "Click me" ); const counter = createElement("span", [ "Number of clicks:", this.clickCount ]); const firstName = createElement("span", ['Value:', 'Hello']); if (this.width % 20 === 0){ console.log(`rendered ${this.width}`) } return createElement( "div", { style: { "background-color": "red", width: `${this.width}px` } }, [firstName] ); } });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
With component
With element
With static value [component]
With static value [element]
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
It seems like you're providing some benchmark data and test results, but I'm not sure what specific question or problem you'd like me to help with. If you're looking for general advice on interpreting this data, here are a few observations: * The test "With element" appears to have the highest execution rate per second across all platforms. * The test "With static value [element]" has a relatively high execution rate per second compared to other variations of the same test. * Chrome 78 is performing well on both Mac OS X 10.14.1 desktop devices. If you could provide more context or specify what aspect of this data you'd like help with, I'll do my best to assist!
Related benchmarks:
Vue.js-method-vs-filters-vs-computed
delete vs this.$delete
vue updated vs watch
innerText vs innerHTML (performance 3)
Comments
Confirm delete:
Do you really want to delete benchmark?