Skip to content

Commit 854b5b7

Browse files
committed
feat(benchmark): add static_tree benchmark
Static binary component tree of depth 10, i.e. 1024 components. Current numbers for `pureScriptTime` are: JavaScript: Baseline: 27.10+-9% Ng2: 26.84+-8% Ng1: 55.30+-14% Dart: Baseline: 30.13+-4% Ng2: 45.94+-3% Ng1: 128.88+-10% I.e. in JS we are same speed as baseline right now! Some background: We had a recent change in the compiler that merges components into their parents already during compilation (angular#2529). This made Ng2 2x faster in this benchmark (before the Ng2 JS time was 49.59+-14%ms). Closes angular#3196
1 parent 231962a commit 854b5b7

File tree

12 files changed

+697
-0
lines changed

12 files changed

+697
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
library benchmarks.e2e_test.static_tree_perf;
2+
3+
main() {
4+
5+
}
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import {runClickBenchmark, verifyNoBrowserErrors} from 'angular2/src/test_lib/perf_util';
2+
3+
describe('ng2 static tree benchmark', function() {
4+
5+
var URL = 'benchmarks/src/static_tree/tree_benchmark.html';
6+
7+
afterEach(verifyNoBrowserErrors);
8+
9+
it('should log the ng stats with viewcache', function(done) {
10+
runClickBenchmark({
11+
url: URL,
12+
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
13+
id: 'ng2.static.tree.create.viewcache',
14+
params: [{name: 'viewcache', value: 'true'}]
15+
}).then(done, done.fail);
16+
});
17+
18+
it('should log the ng stats without viewcache', function(done) {
19+
runClickBenchmark({
20+
url: URL,
21+
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
22+
id: 'ng2.static.tree.create.plain',
23+
params: [{name: 'viewcache', value: 'false'}]
24+
}).then(done, done.fail);
25+
});
26+
27+
it('should log the ng stats (update)', function(done) {
28+
runClickBenchmark({
29+
url: URL,
30+
buttons: ['#ng2CreateDom'],
31+
id: 'ng2.static.tree.update',
32+
params: [{name: 'viewcache', value: 'true'}]
33+
}).then(done, done.fail);
34+
});
35+
36+
it('should log the baseline stats', function(done) {
37+
runClickBenchmark({
38+
url: URL,
39+
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
40+
id: 'baseline.tree.create',
41+
params: [{name: 'depth', value: 9, scale: 'log2'}]
42+
}).then(done, done.fail);
43+
});
44+
45+
it('should log the baseline stats (update)', function(done) {
46+
runClickBenchmark({
47+
url: URL,
48+
buttons: ['#baselineCreateDom'],
49+
id: 'baseline.tree.update',
50+
params: [{name: 'depth', value: 9, scale: 'log2'}]
51+
}).then(done, done.fail);
52+
});
53+
54+
});

modules/benchmarks/src/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
<li>
2121
<a href="tree/tree_benchmark.html">Tree benchmark</a>
2222
</li>
23+
<li>
24+
<a href="static_tree/tree_benchmark.html">Static tree benchmark</a>
25+
</li>
2326
<li>
2427
<a href="naive_infinite_scroll/index.html">Naive infinite scroll benchmark</a>
2528
</li>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!doctype html>
2+
<html>
3+
<body>
4+
5+
<h2>Params</h2>
6+
<form>
7+
<br>
8+
Use Viewcache:
9+
<label>
10+
Yes<input type="radio" name="viewcache" placeholder="use viewcache" value="true" checked="checked">
11+
</label>
12+
<label>
13+
No<input type="radio" name="viewcache" placeholder="use viewcache" value="false">
14+
</label>
15+
<br>
16+
<button>Apply</button>
17+
</form>
18+
19+
<h2>Angular2 static tree benchmark (depth 10)</h2>
20+
<p>
21+
<button id="ng2DestroyDom">destroyDom</button>
22+
<button id="ng2CreateDom">createDom</button>
23+
<button id="ng2UpdateDomProfile">profile updateDom</button>
24+
<button id="ng2CreateDomProfile">profile createDom</button>
25+
</p>
26+
27+
<h2>Baseline static tree benchmark (depth 10)</h2>
28+
<p>
29+
<button id="baselineDestroyDom">destroyDom</button>
30+
<button id="baselineCreateDom">createDom</button>
31+
<button id="baselineUpdateDomProfile">profile updateDom</button>
32+
<button id="baselineCreateDomProfile">profile createDom</button>
33+
</p>
34+
35+
<div>
36+
<app></app>
37+
</div>
38+
39+
<div>
40+
<baseline></baseline>
41+
</div>
42+
43+
$SCRIPTS$
44+
</body>
45+
</html>

0 commit comments

Comments
 (0)