Skip to content

Commit

Permalink
saved changes where vdom perf is good again
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Apr 4, 2016
1 parent f0e9b26 commit 527e7aa
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1,006 deletions.
2 changes: 1 addition & 1 deletion examples/vdom-bench/index.html
Expand Up @@ -15,7 +15,7 @@ <h1>Virtual DOM Benchmark: <a href="https://github.com/trueadm/inferno">InfernoJ
<button id="RunButton" disabled="true">Run</button>

<script src="dist/inferno.min.js"></script>
<script src="dist/inferno-dom.min.js"></script>
<script src="dist/inferno-dom.js"></script>
<script src="main.js"></script>
</body>
</html>
43 changes: 21 additions & 22 deletions examples/vdom-bench/main.js
Expand Up @@ -24,6 +24,23 @@
tag: 'span'
};

function createNode1(tpl, children) {
return {
tpl: tpl,
dom: null,
children: children
};
}

function createNode2(tpl, key, children) {
return {
tpl: tpl,
dom: null,
key: key,
children: children
};
}

function renderTree(nodes) {
var children = new Array(nodes.length);
var i;
Expand All @@ -32,19 +49,9 @@
for (i = 0; i < nodes.length; i++) {
n = nodes[i];
if (n.children !== null) {
children[i] = {
tpl: t1,
dom: null,
key: n.key,
children: renderTree(n.children)
};
children[i] = createNode2(t1, n.key, renderTree(n.children));
} else {
children[i] = {
tpl: t2,
dom: null,
key: n.key,
children: n.key
};
children[i] = createNode2(t2, n.key, n.key);
}
}
return children;
Expand All @@ -64,19 +71,11 @@
};

BenchmarkImpl.prototype.render = function() {
InfernoDOM.render({
tpl: t1,
dom: null,
children: renderTree(this.a)
}, this.container);
InfernoDOM.render(createNode1(t1, renderTree(this.a)), this.container);
};

BenchmarkImpl.prototype.update = function() {
InfernoDOM.render({
tpl: t1,
dom: null,
children: renderTree(this.b)
}, this.container);
InfernoDOM.render(createNode1(t1, renderTree(this.b)), this.container);
};

document.addEventListener('DOMContentLoaded', function() {
Expand Down

0 comments on commit 527e7aa

Please sign in to comment.