-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench.js
87 lines (76 loc) · 1.71 KB
/
bench.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function bench (fn, n) {
var s = Date.now()
var vms = []
for (var i = 0; i < n; i++) {
vms.push(fn())
}
console.log(n + ' ' + fn.desciption + ': ' + (Date.now() - s) + 'ms')
}
function emptyInstance () {
return new Vue()
}
emptyInstance.desciption = 'empty instances'
var options = {
template: '{{hi}}',
data: function () {
return {
hi: 'msg'
}
},
ready: function () {},
filters: {
that: function () {}
}
}
function instanceWithOption () {
return new Vue(options)
}
instanceWithOption.desciption = 'instance with options'
var Test = Vue.extend(options)
function extendedInstance () {
return new Test()
}
extendedInstance.desciption = 'extended instances'
function extendedInstanceWithOptions () {
return new Test({
data: function () {
return {
b: 'lol'
}
},
ready: function () {},
directives: {
that: function () {
}
}
})
}
extendedInstanceWithOptions.desciption = 'extended instances with options'
bench(emptyInstance, 100)
bench(emptyInstance, 1000)
bench(emptyInstance, 10000)
bench(instanceWithOption, 100)
bench(instanceWithOption, 1000)
bench(instanceWithOption, 10000)
bench(extendedInstance, 100)
bench(extendedInstance, 1000)
bench(extendedInstance, 10000)
bench(extendedInstanceWithOptions, 100)
bench(extendedInstanceWithOptions, 1000)
bench(extendedInstanceWithOptions, 10000)
// TODO:
//
// - rendering performance
// - simple v-repeat
// - component v-repeat
// - v-repeat with nested components
//
// - data observation performance
// - simple objects
// - complex objects
// - small array
// - large array
//
// - dependency tracking performance
// - simple watcher
// - complex watcher