diff --git a/build.sh b/build.sh index 546e3c189a..bf466d076f 100755 --- a/build.sh +++ b/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 diff --git a/modules/benchmarks/e2e_test/tree_perf.ts b/modules/benchmarks/e2e_test/tree_perf.ts index 7c0e920b96..845b468875 100644 --- a/modules/benchmarks/e2e_test/tree_perf.ts +++ b/modules/benchmarks/e2e_test/tree_perf.ts @@ -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', diff --git a/modules/benchmarks/e2e_test/tree_spec.ts b/modules/benchmarks/e2e_test/tree_spec.ts index d28ba2d34a..2eba0d9525 100644 --- a/modules/benchmarks/e2e_test/tree_spec.ts +++ b/modules/benchmarks/e2e_test/tree_spec.ts @@ -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', diff --git a/modules/benchmarks/src/bootstrap_polymer.ts b/modules/benchmarks/src/bootstrap_plain.ts similarity index 84% rename from modules/benchmarks/src/bootstrap_polymer.ts rename to modules/benchmarks/src/bootstrap_plain.ts index d6d1cf56e5..2ea20a188c 100644 --- a/modules/benchmarks/src/bootstrap_polymer.ts +++ b/modules/benchmarks/src/bootstrap_plain.ts @@ -14,7 +14,10 @@ (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)); diff --git a/modules/benchmarks/src/tree/baseline/index.ts b/modules/benchmarks/src/tree/baseline/index.ts index 96f1e3a967..9e90915ee7 100644 --- a/modules/benchmarks/src/tree/baseline/index.ts +++ b/modules/benchmarks/src/tree/baseline/index.ts @@ -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(); diff --git a/modules/benchmarks/src/tree/incremental_dom/index.html b/modules/benchmarks/src/tree/incremental_dom/index.html new file mode 100644 index 0000000000..8cd5386fab --- /dev/null +++ b/modules/benchmarks/src/tree/incremental_dom/index.html @@ -0,0 +1,27 @@ + + + + +

Params

+
+ Depth: + +
+ +
+ +

Baseline tree benchmark

+

+ + + + +

+ +
+ +
+ + + + \ No newline at end of file diff --git a/modules/benchmarks/src/tree/incremental_dom/index.ts b/modules/benchmarks/src/tree/incremental_dom/index.ts new file mode 100644 index 0000000000..dffb8c8ce2 --- /dev/null +++ b/modules/benchmarks/src/tree/incremental_dom/index.ts @@ -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(); +} diff --git a/modules/benchmarks/src/tree/incremental_dom/tree.ts b/modules/benchmarks/src/tree/incremental_dom/tree.ts new file mode 100644 index 0000000000..808ccfd676 --- /dev/null +++ b/modules/benchmarks/src/tree/incremental_dom/tree.ts @@ -0,0 +1,26 @@ +import {TreeNode} from '../util'; +const {elementOpen, elementClose, text} = require('incremental-dom'); + +// template: +// {{data.value}} +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'); +} diff --git a/modules/benchmarks/src/tree/ng2/index.ts b/modules/benchmarks/src/tree/ng2/index.ts index a7f9c46bd9..68ae9d6cb5 100644 --- a/modules/benchmarks/src/tree/ng2/index.ts +++ b/modules/benchmarks/src/tree/ng2/index.ts @@ -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')); }); } diff --git a/modules/benchmarks/src/tree/polymer/index.html b/modules/benchmarks/src/tree/polymer/index.html index 6da43b09c7..3a507d9d48 100644 --- a/modules/benchmarks/src/tree/polymer/index.html +++ b/modules/benchmarks/src/tree/polymer/index.html @@ -23,7 +23,7 @@ - + diff --git a/modules/benchmarks/src/tree/polymer_leaves/index.html b/modules/benchmarks/src/tree/polymer_leaves/index.html index 5ed31cde32..b206ebf440 100644 --- a/modules/benchmarks/src/tree/polymer_leaves/index.html +++ b/modules/benchmarks/src/tree/polymer_leaves/index.html @@ -23,7 +23,7 @@ - +