1
1
<template >
2
+ <h1 >Working Demo:</h1 >
2
3
<Counter :value =" 3" />
4
+ <br />
5
+ <hr />
6
+ <div >
7
+ <h1 >Perfomance Evaluation:</h1 >
8
+ <div class =" vertical-panel" >
9
+ <h2 >Function Style:</h2 >
10
+ <button type =" button" @click =" onEvaluateFunctionStyle" >Start</button >
11
+ <div >
12
+ Time taken : {{ functionStyleEndTime - functionStyleStartTime }} ms |
13
+ Memory Used : {{ functionStyleEndMem - functionStyleStartMem }}
14
+ </div >
15
+ <div class =" test-panel" >
16
+ <CounterFunctionStyle
17
+ v-for =" index in functionStyleCount"
18
+ :key =" index"
19
+ :value =" index"
20
+ :hide-buttons =" true"
21
+ @all-mounted =" allFunctionStyleComponentsUpdated"
22
+ />
23
+ </div >
24
+ </div >
25
+ <div class =" vertical-panel" >
26
+ <h2 >Class Style:</h2 >
27
+ <button type =" button" @click =" onEvaluateClassStyle" >Start</button >
28
+ <div >
29
+ Time taken : {{ classStyleEndTime - classStyleStartTime }} ms |
30
+ Memory Used : {{ classStyleEndMem - classStyleStartMem }}
31
+ </div >
32
+ <div class =" test-panel" >
33
+ <Counter
34
+ v-for =" index in classStyleCount"
35
+ :key =" index"
36
+ :value =" index"
37
+ :hide-buttons =" true"
38
+ @all-mounted =" allClassStyleComponentsUpdated"
39
+ />
40
+ </div >
41
+ </div >
42
+ </div >
3
43
</template >
4
44
5
45
<script lang="ts">
6
46
import { defineComponent } from " vue" ;
7
47
import Counter from " ./components/Counter.vue" ;
48
+ import CounterFunctionStyle from " ./components/CounterFunctionStyle.vue" ;
49
+
50
+ export const TEST_COUNT = 10000 ;
8
51
9
52
export default defineComponent ({
10
53
name: " App" ,
11
54
components: {
12
- Counter
55
+ Counter ,
56
+ CounterFunctionStyle
57
+ },
58
+ setup() {
59
+ return {
60
+ functionStyleStartTime: 0 ,
61
+ functionStyleStartMem: 0 ,
62
+
63
+ classStyleStartTime: 0 ,
64
+ classStyleStartMem: 0
65
+ };
66
+ },
67
+ data() {
68
+ return {
69
+ functionStyleCount: 0 ,
70
+ functionStyleEndTime: 0 ,
71
+ functionStyleEndMem: 0 ,
72
+
73
+ classStyleCount: 0 ,
74
+ classStyleEndTime: 0 ,
75
+ classStyleEndMem: 0
76
+ };
77
+ },
78
+ methods: {
79
+ onEvaluateFunctionStyle(): void {
80
+ this .functionStyleStartTime = Date .now ();
81
+ this .functionStyleStartMem = (performance as any ).memory .usedJSHeapSize ;
82
+
83
+ this .functionStyleCount = TEST_COUNT ;
84
+ },
85
+ onEvaluateClassStyle(): void {
86
+ this .classStyleStartTime = Date .now ();
87
+ this .classStyleStartMem = (performance as any ).memory .usedJSHeapSize ;
88
+
89
+ this .classStyleCount = TEST_COUNT ;
90
+ },
91
+ allFunctionStyleComponentsUpdated(): void {
92
+ this .functionStyleEndTime = Date .now ();
93
+ setTimeout (
94
+ () =>
95
+ (this .functionStyleEndMem = (performance as any ).memory .usedJSHeapSize ),
96
+ 1000
97
+ );
98
+ },
99
+ allClassStyleComponentsUpdated(): void {
100
+ this .classStyleEndTime = Date .now ();
101
+ setTimeout (
102
+ () =>
103
+ (this .classStyleEndMem = (performance as any ).memory .usedJSHeapSize ),
104
+ 1000
105
+ );
106
+ }
13
107
}
14
108
});
15
109
</script >
@@ -23,4 +117,19 @@ export default defineComponent({
23
117
color : #2c3e50 ;
24
118
margin-top : 60px ;
25
119
}
120
+
121
+ .vertical-panel {
122
+ width : 40% ;
123
+ display : inline-block ;
124
+
125
+ vertical-align : top ;
126
+
127
+ .test-panel {
128
+ border : 1px solid silver ;
129
+ margin : 10px 30px ;
130
+ padding : 5px ;
131
+
132
+ font-size : 0.5em ;
133
+ }
134
+ }
26
135
</style >
0 commit comments