forked from infernojs/inferno
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
63 lines (53 loc) · 1.37 KB
/
Copy pathapp.js
File metadata and controls
63 lines (53 loc) · 1.37 KB
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
(function() {
"use strict";
// https://jsfiddle.net/bhvfe8qd/
// https://jsfiddle.net/oLwa7ysr/
/* (flags, type, props, children, key, ref, noNormalise) */
var createVNode = Inferno.createVNode;
var Component = Inferno.Component;
var createElement = Inferno.createElement;
let renderCounter = 0;
class ListItem extends Component {
render() {
renderCounter++;
return createElement('li', null, this.props.children);
}
}
class List extends Component {
constructor() {
super();
// set initial time:
this.state = {
items: []
};
this.items = [];
}
componentDidMount() {
let i = 0;
while (this.items.length < 2000) {
this.items[this.items.length] = createElement(ListItem, {key: ++i}, `${this.items.length}bar`);
this.setState({ items: this.items });
}
}
render() {
return createElement('ul', null, this.state.items);
}
}
document.addEventListener('DOMContentLoaded', function () {
var container = document.querySelector('#App');
const times = [];
const count = 2;
let totalTime = 0;
for (var i = 0; i < count; i++) {
Inferno.render(createElement(List), container);
}
setTimeout(function () {
Inferno.render(createElement('div', null, `
Rounds: ${count},
Average: ${totalTime / count},
Total: ${totalTime},
counter: ${renderCounter}
`), container);
}, 5000);
});
})();