-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (33 loc) · 824 Bytes
/
index.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
var yo = require('yo-yo')
var updateWithEvents = require('./updateWithEvents')
var deep = 100
var count = 0
console.time('create tree')
var root = yo`<ul><li>root</li></ul>`
for (var i = 0; i < deep; i++) {
root = createElement(root)
}
console.timeEnd('create tree')
document.body.appendChild(root)
var newroot = yo`<ul><li>newroot</li></ul>`
for (var i = 0; i < deep; i++) {
newroot = createElement(newroot)
}
console.time('update')
yo.update(root, newroot)
console.timeEnd('update')
newroot = yo`<ul><li>newroot</li></ul>`
for (var i = 0; i < deep; i++) {
newroot = createElement(newroot)
}
console.time('update with events')
updateWithEvents(root, newroot)
console.timeEnd('update with events')
function createElement (child) {
return yo`<ul>
<li>
${count++}
${child}
</li>
</ul>`
}