Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit b58a866

Browse files
vsavkinchirayuk
authored andcommitted
benchmark(tree): add transcluding components to the TreeComponent benchmark
Closes #1332
1 parent cb3ddd0 commit b58a866

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

benchmark/web/bp.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,21 @@ bp.Runner.runTimedTest = function (bs) {
133133
if (typeof window.gc === 'function') {
134134
window.gc();
135135
}
136+
var memory = performance.memory ? performance.memory : {usedJSHeapSize: NaN};
136137

137-
beforeHeap = performance.memory.usedJSHeapSize;
138+
beforeHeap = memory.usedJSHeapSize;
138139
startTime = bp.Measure.numMilliseconds();
139140
bs.fn();
140141
endTime = bp.Measure.numMilliseconds() - startTime;
141-
afterHeap = performance.memory.usedJSHeapSize;
142+
afterHeap = memory.usedJSHeapSize;
142143

143144
startGCTime = bp.Measure.numMilliseconds();
144145
if (typeof window.gc === 'function') {
145146
window.gc();
146147
}
147148
endGCTime = bp.Measure.numMilliseconds() - startGCTime;
148149

149-
finalHeap = performance.memory.usedJSHeapSize;
150+
finalHeap = memory.usedJSHeapSize;
150151
garbage = Math.abs(finalHeap - afterHeap);
151152
retainedMemory = finalHeap - beforeHeap;
152153
return {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<span> {{ctrl.data.value}}
2+
<span ng-if="ctrl.data.right != null"><transcluding-tree-url data=ctrl.data.right></span>
3+
<span ng-if="ctrl.data.left != null"><transcluding-tree-url data=ctrl.data.left></span>
4+
</span>

benchmark/web/tree.dart

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,41 @@ import 'dart:js' as js;
1414
'<span ng-if="ctrl.data.right != null"><tree data=ctrl.data.right></span>'
1515
'<span ng-if="ctrl.data.left != null"><tree data=ctrl.data.left></span>'
1616
'</span>',
17-
publishAs: 'ctrl')
17+
publishAs: 'ctrl',
18+
useShadowDom: true)
1819
class TreeComponent {
1920
@NgOneWay('data')
2021
var data;
2122
}
2223

24+
@Component(
25+
selector: 'transcluding-tree',
26+
template: '<span> {{ctrl.data.value}}'
27+
'<span ng-if="ctrl.data.right != null"><transcluding-tree data=ctrl.data.right></span>'
28+
'<span ng-if="ctrl.data.left != null"><transcluding-tree data=ctrl.data.left></span>'
29+
'</span>',
30+
publishAs: 'ctrl',
31+
useShadowDom: false)
32+
class TranscludingTreeComponent extends TreeComponent {}
33+
34+
2335
@Component(
2436
selector: 'tree-url',
2537
templateUrl: 'tree-tmpl.html',
26-
publishAs: 'ctrl')
38+
publishAs: 'ctrl',
39+
useShadowDom: true)
2740
class TreeUrlComponent {
2841
@NgOneWay('data')
2942
var data;
3043
}
3144

45+
@Component(
46+
selector: 'transcluding-tree-url',
47+
templateUrl: 'transcluding-tree-tmpl.html',
48+
publishAs: 'ctrl',
49+
useShadowDom: false)
50+
class TranscludingTreeUrlComponent extends TreeUrlComponent {}
51+
3252

3353
// This is a baseline implementation of TreeComponent.
3454
// It assumes the data never changes and simply throws elements on the DOM
@@ -250,7 +270,9 @@ main() {
250270

251271
var module = new Module()
252272
..bind(TreeComponent)
273+
..bind(TranscludingTreeComponent)
253274
..bind(TreeUrlComponent)
275+
..bind(TranscludingTreeUrlComponent)
254276
..bind(NgFreeTree)
255277
..bind(NgFreeTreeScoped)
256278
..bind(NgFreeTreeClass)

benchmark/web/tree.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<html>
22
<head>
33
<title>TreeComponent Benchmark</title>
4+
5+
<!-- Uncomment to test in Firefox -->
6+
<!--<script src="packages/web_components/platform.js"></script>-->
7+
<!--<script src="packages/web_components/dart_support.js"></script>-->
8+
49
<script src="underscore.js"></script>
510
<script src="bp.js"></script>
611
<script src="tree.dart" type="application/dart"></script>
@@ -129,14 +134,18 @@
129134
</p>
130135

131136
<div>Default: <input type=checkbox ng-model="useDefault"></div>
137+
<div>Transcluding: <input type=checkbox ng-model="useTranscluding"></div>
132138
<div>From URL: <input type=checkbox ng-model="useUrl"></div>
139+
<div>Transcluding from URL: <input type=checkbox ng-model="useTranscludingFromUrl"></div>
133140
<div>Baseline: <input type=checkbox ng-model="useBaseline"></div>
134141
<div>Baseline + scope: <input type=checkbox ng-model="useBaselineScoped"></div>
135142
<div>Baseline + class: <input type=checkbox ng-model="useBaselineClass"></div>
136143

137144

138145
<tree ng-if="useDefault" data=initData></tree>
146+
<transcluding-tree ng-if="useTranscluding" data=initData></transcluding-tree>
139147
<tree-url ng-if="useUrl" data=initData></tree-url>
148+
<transcluding-tree-url ng-if="useTranscludingFromUrl" data=initData></transcluding-tree-url>
140149

141150
<ng-free-tree ng-if="useBaseline" data=initData></ng-free-tree>
142151
<ng-free-tree-scoped ng-if="useBaselineScoped" data=initData></ng-free-tree-scoped>

0 commit comments

Comments
 (0)