feat(benchmarks): add incremental-dom version of deep tree benchmark
This commit is contained in:
parent
27d72e87c3
commit
2581c0851a
1
build.sh
1
build.sh
|
@ -45,6 +45,7 @@ ln -s ../../../../node_modules/reflect-metadata/Reflect.js .
|
|||
ln -s ../../../../node_modules/rxjs .
|
||||
ln -s ../../../../node_modules/angular/angular.js .
|
||||
ln -s ../../../../bower_components/polymer .
|
||||
ln -s ../../../../node_modules/incremental-dom/dist/incremental-dom-cjs.js
|
||||
cd -
|
||||
|
||||
TSCONFIG=./modules/tsconfig.json
|
||||
|
|
|
@ -41,6 +41,15 @@ describe('tree benchmark perf', () => {
|
|||
ignoreBrowserSynchronization: true,
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should run for the incremental dom', (done) => {
|
||||
runTreeBenchmark({
|
||||
id: 'deepTree.incrementalDom',
|
||||
url: 'all/benchmarks/src/tree/incremental_dom/index.html',
|
||||
ignoreBrowserSynchronization: true,
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should run for polymer binary tree', (done) => {
|
||||
runTreeBenchmark({
|
||||
id: 'deepTree.polymer',
|
||||
|
|
|
@ -37,6 +37,14 @@ describe('tree benchmark spec', () => {
|
|||
ignoreBrowserSynchronization: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should work for the incremental dom', () => {
|
||||
testTreeBenchmark({
|
||||
url: 'all/benchmarks/src/tree/incremental_dom/index.html',
|
||||
ignoreBrowserSynchronization: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('should work for polymer binary tree', () => {
|
||||
testTreeBenchmark({
|
||||
url: 'all/benchmarks/src/tree/polymer/index.html',
|
||||
|
|
|
@ -14,7 +14,10 @@
|
|||
(<any>global).benchmarksBootstrap = benchmarksBootstrap;
|
||||
|
||||
function benchmarksBootstrap() {
|
||||
System.config({defaultJSExtensions: true});
|
||||
System.config({
|
||||
defaultJSExtensions: true,
|
||||
map: {'incremental-dom': '/all/benchmarks/vendor/incremental-dom-cjs.js'}
|
||||
});
|
||||
|
||||
// BOOTSTRAP the app!
|
||||
System.import('index').then(function(m: any) { m.main(); }, console.error.bind(console));
|
|
@ -18,8 +18,8 @@ export function main() {
|
|||
bindAction('#destroyDom', destroyDom);
|
||||
bindAction('#createDom', createDom);
|
||||
|
||||
bindAction('#updateDomProfile', profile(createDom, noop, 'baseline-update'));
|
||||
bindAction('#createDomProfile', profile(createDom, destroyDom, 'baseline-create'));
|
||||
bindAction('#updateDomProfile', profile(createDom, noop, 'update'));
|
||||
bindAction('#createDomProfile', profile(createDom, destroyDom, 'create'));
|
||||
}
|
||||
|
||||
init();
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h2>Params</h2>
|
||||
<form>
|
||||
Depth:
|
||||
<input type="number" name="depth" placeholder="depth" value="9">
|
||||
<br>
|
||||
<button>Apply</button>
|
||||
</form>
|
||||
|
||||
<h2>Baseline tree benchmark</h2>
|
||||
<p>
|
||||
<button id="destroyDom">destroyDom</button>
|
||||
<button id="createDom">createDom</button>
|
||||
<button id="updateDomProfile">profile updateDom</button>
|
||||
<button id="createDomProfile">profile createDom</button>
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<tree id="root"></tree>
|
||||
</div>
|
||||
|
||||
<script src="../../bootstrap_plain.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,26 @@
|
|||
import {bindAction, profile} from '../../util';
|
||||
import {TreeNode, buildTree, emptyTree} from '../util';
|
||||
import {render} from './tree';
|
||||
const {patch} = require('incremental-dom');
|
||||
|
||||
export function main() {
|
||||
var app: any;
|
||||
|
||||
function destroyDom() { patch(app, () => render(emptyTree)); }
|
||||
|
||||
function createDom() { patch(app, () => render(buildTree())); }
|
||||
|
||||
function noop() {}
|
||||
|
||||
function init() {
|
||||
app = document.querySelector('tree');
|
||||
|
||||
bindAction('#destroyDom', destroyDom);
|
||||
bindAction('#createDom', createDom);
|
||||
|
||||
bindAction('#updateDomProfile', profile(createDom, noop, 'update'));
|
||||
bindAction('#createDomProfile', profile(createDom, destroyDom, 'create'));
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import {TreeNode} from '../util';
|
||||
const {elementOpen, elementClose, text} = require('incremental-dom');
|
||||
|
||||
// template:
|
||||
// <span> {{data.value}} <span template='ngIf data.right != null'><tree
|
||||
// [data]='data.right'></tree></span><span template='ngIf data.left != null'><tree
|
||||
// [data]='data.left'></tree></span></span>
|
||||
export function render(data: TreeNode) {
|
||||
elementOpen('span', '', null);
|
||||
text(` ${data.value} `);
|
||||
if (data.left) {
|
||||
elementOpen('span', '', null);
|
||||
elementOpen('tree', '', null);
|
||||
render(data.left);
|
||||
elementClose('tree');
|
||||
elementClose('span');
|
||||
}
|
||||
if (data.right) {
|
||||
elementOpen('span', '', null);
|
||||
elementOpen('tree', '', null);
|
||||
render(data.right);
|
||||
elementClose('tree');
|
||||
elementClose('span');
|
||||
}
|
||||
elementClose('span');
|
||||
}
|
|
@ -31,8 +31,8 @@ export function main() {
|
|||
tree = appRef.components[0].instance;
|
||||
bindAction('#destroyDom', destroyDom);
|
||||
bindAction('#createDom', createDom);
|
||||
bindAction('#updateDomProfile', profile(createDom, noop, 'ng2-update'));
|
||||
bindAction('#createDomProfile', profile(createDom, destroyDom, 'ng2-create'));
|
||||
bindAction('#updateDomProfile', profile(createDom, noop, 'update'));
|
||||
bindAction('#createDomProfile', profile(createDom, destroyDom, 'create'));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<binary-tree id="root"></binary-tree>
|
||||
</div>
|
||||
|
||||
<script src="../../bootstrap_polymer.js"></script>
|
||||
<script src="../../bootstrap_plain.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<binary-tree id="root"></binary-tree>
|
||||
</div>
|
||||
|
||||
<script src="../../bootstrap_polymer.js"></script>
|
||||
<script src="../../bootstrap_plain.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue