chore: format benchmarks

closes #11112
This commit is contained in:
Tobias Bosch 2016-08-26 15:44:05 -07:00 committed by Victor Berchet
parent 61002733bc
commit c377e80670
25 changed files with 248 additions and 345 deletions

View File

@ -13,15 +13,14 @@ describe('ng2 naive infinite scroll benchmark', function() {
url: URL,
id: 'ng2.naive_infinite_scroll',
work: function() {
browser.wait(protractor.until.elementLocated(protractor.By.css('body /deep/ #scrollDiv')),
5000);
browser.wait(
protractor.until.elementLocated(protractor.By.css('body /deep/ #scrollDiv')), 5000);
$('#reset-btn').click();
$('#run-btn').click();
browser.wait(protractor.until.elementLocated(protractor.By.css('#done')), 10000);
},
params: [
{name: 'appSize', value: appSize},
{name: 'iterationCount', value: 20, scale: 'linear'},
{name: 'appSize', value: appSize}, {name: 'iterationCount', value: 20, scale: 'linear'},
{name: 'scrollIncrement', value: 40}
]
}).then(done, done.fail);

View File

@ -16,7 +16,8 @@ describe('ng2 naive infinite scroll benchmark', function() {
var stageButtons = `${ allScrollItems } .row stage-buttons button`;
var count = function(selector) {
return browser.executeScript(`return ` +
return browser.executeScript(
`return ` +
`document.querySelectorAll("${ selector }").length;`);
};
@ -25,7 +26,8 @@ describe('ng2 naive infinite scroll benchmark', function() {
};
var firstTextOf = function(selector) {
return browser.executeScript(`return ` +
return browser.executeScript(
`return ` +
`document.querySelector("${ selector }").innerText;`);
};
@ -36,18 +38,17 @@ describe('ng2 naive infinite scroll benchmark', function() {
count(cells).then(function(c) { expect(c).toEqual(expectedRowCount * expectedCellsPerRow); });
// Click on first enabled button and verify stage changes
firstTextOf(`${ stageButtons }:enabled`)
.then(function(text) {
firstTextOf(`${ stageButtons }:enabled`).then(function(text) {
expect(text).toEqual('Pitched');
clickFirstOf(`${ stageButtons }:enabled`)
.then(function() {
firstTextOf(`${ stageButtons }:enabled`)
.then(function(text) { expect(text).toEqual('Won'); })
clickFirstOf(`${ stageButtons }:enabled`).then(function() {
firstTextOf(`${ stageButtons }:enabled`).then(function(text) {
expect(text).toEqual('Won');
})
});
});
$("#reset-btn").click();
$("#run-btn").click();
$('#reset-btn').click();
$('#run-btn').click();
browser.wait(() => {
return $('#done').getText().then(function() { return true; }, function() { return false; });
}, 10000);

View File

@ -9,15 +9,15 @@ describe('ng2 largetable benchmark', function() {
it('should log the load time', function(done) {
runner.sample({
runner
.sample({
id: 'loadTime',
prepare: null,
microMetrics: null,
userMetrics:
{loadTime: 'The time in milliseconds to bootstrap', someConstant: 'Some constant'},
bindings: [
benchpress.bind(benchpress.SizeValidator.SAMPLE_SIZE)
.toValue(2),
benchpress.bind(benchpress.SizeValidator.SAMPLE_SIZE).toValue(2),
benchpress.bind(benchpress.RegressionSlopeValidator.SAMPLE_SIZE).toValue(2),
benchpress.bind(benchpress.RegressionSlopeValidator.METRIC).toValue('someConstant')
],

View File

@ -1,16 +1,11 @@
import {PromiseWrapper} from '@angular/facade/src/async';
import {ListWrapper, Map, MapWrapper} from '@angular/facade/src/collection';
import {DateWrapper, Type, isPresent, print} from '@angular/facade/src/lang';
import {bootstrap} from '@angular/platform-browser';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {PromiseWrapper} from '@angular/facade/src/async';
import {ListWrapper, Map, MapWrapper} from '@angular/facade/src/collection';
import {DateWrapper, Type, print, isPresent} from '@angular/facade/src/lang';
import {
ComponentResolver,
Component,
Directive,
ViewContainerRef,
} from '@angular/core';
import {ComponentResolver, Component, Directive, ViewContainerRef,} from '@angular/core';
import {ViewMetadata} from '@angular/core/src/metadata/view';
@ -23,26 +18,27 @@ function _createBindings(): any[] {
return [
{
provide: DirectiveResolver,
useFactory: () => new MultiplyDirectiveResolver(
multiplyTemplatesBy,
[BenchmarkComponentNoBindings, BenchmarkComponentWithBindings]),
useFactory:
() => new MultiplyDirectiveResolver(
multiplyTemplatesBy, [BenchmarkComponentNoBindings, BenchmarkComponentWithBindings]),
deps: []
},
// Use interpretative mode as Dart does not support JIT and
// we want to be able to compare the numbers between JS and Dart
{provide: CompilerConfig, useValue: new CompilerConfig({genDebugInfo: false, useJit: false, logBindingUpdate: false})}
{
provide: CompilerConfig,
useValue: new CompilerConfig({genDebugInfo: false, useJit: false, logBindingUpdate: false})
}
];
}
export function main() {
BrowserDomAdapter.makeCurrent();
bootstrap(CompilerAppComponent, _createBindings())
.then((ref) => {
bootstrap(CompilerAppComponent, _createBindings()).then((ref) => {
var app = ref.instance;
bindAction('#compileNoBindings',
measureWrapper(() => app.compileNoBindings(), 'No Bindings'));
bindAction('#compileWithBindings',
measureWrapper(() => app.compileWithBindings(), 'With Bindings'));
bindAction('#compileNoBindings', measureWrapper(() => app.compileNoBindings(), 'No Bindings'));
bindAction(
'#compileWithBindings', measureWrapper(() => app.compileWithBindings(), 'With Bindings'));
});
}

View File

@ -1,8 +1,8 @@
import {SelectorMatcher} from '@angular/compiler/src/selector';
import {CssSelector} from '@angular/compiler/src/selector';
import {StringWrapper, Math} from '@angular/facade/lang';
import {getIntParameter, bindAction} from '@angular/testing/src/benchmark_util';
import {Math, StringWrapper} from '@angular/facade/lang';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import {bindAction, getIntParameter} from '@angular/testing/src/benchmark_util';
export function main() {
BrowserDomAdapter.makeCurrent();

View File

@ -1,11 +1,11 @@
import {bootstrap} from '@angular/platform-browser';
import {NgFor, NgIf} from '@angular/common';
import {Component, Directive, DynamicComponentLoader, ViewContainerRef} from '@angular/core';
import {NgIf, NgFor} from '@angular/common';
import {ApplicationRef} from '@angular/core/src/application_ref';
import {ListWrapper} from '@angular/facade/src/lang';
import {getIntParameter, bindAction} from '@angular/testing/src/benchmark_util';
import {bootstrap} from '@angular/platform-browser';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {bindAction, getIntParameter} from '@angular/testing/src/benchmark_util';
var testList = null;
@ -13,8 +13,7 @@ export function main() {
var size = getIntParameter('size');
testList = ListWrapper.createFixedSize(size);
platformBrowserDynamic().bootstrapModule(AppModule)
.then((ref) => {
platformBrowserDynamic().bootstrapModule(AppModule).then((ref) => {
var injector = ref.injector;
var app: AppComponent = ref.instance;
var appRef = injector.get(ApplicationRef);
@ -110,9 +109,6 @@ class AppComponent {
@NgModule({
imports: [BrowserModule],
bootstrap: [AppComponent]
})
@NgModule({imports: [BrowserModule], bootstrap: [AppComponent]})
class AppModule {
}

View File

@ -1,8 +1,8 @@
import {Injectable, ReflectiveInjector, ReflectiveKey} from '@angular/core';
import {reflector} from '@angular/core/src/reflection/reflection';
import {ReflectionCapabilities} from '@angular/core/src/reflection/reflection_capabilities';
import {getIntParameter, bindAction, microBenchmark} from '@angular/testing/src/benchmark_util';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import {bindAction, getIntParameter, microBenchmark} from '@angular/testing/src/benchmark_util';
var count = 0;
@ -81,7 +81,8 @@ export function main() {
bindAction('#getChild', () => microBenchmark('injectAvg', iterations, getChild));
bindAction('#instantiate', () => microBenchmark('injectAvg', iterations, instantiate));
bindAction('#createVariety', () => microBenchmark('injectAvg', iterations, createVariety));
bindAction('#createVarietyResolved',
bindAction(
'#createVarietyResolved',
() => microBenchmark('injectAvg', iterations, createVarietyResolved));
}

View File

@ -1,22 +1,14 @@
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {window, document, gc} from '@angular/facade/src/browser';
import {
getIntParameter,
getStringParameter,
bindAction,
windowProfile,
windowProfileEnd
} from '@angular/testing/src/benchmark_util';
import {bootstrap} from '@angular/platform-browser';
import {Component} from '@angular/core';
import {NgFor, NgSwitch, NgSwitchCase, NgSwitchDefault} from '@angular/common';
import {Component} from '@angular/core';
import {ApplicationRef} from '@angular/core/src/application_ref';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import {ListWrapper} from '@angular/facade/src/collection';
import {Inject} from '@angular/core/src/di/decorators';
import {reflector} from '@angular/core/src/reflection/reflection';
import {document, gc, window} from '@angular/facade/src/browser';
import {ListWrapper} from '@angular/facade/src/collection';
import {bootstrap} from '@angular/platform-browser';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {bindAction, getIntParameter, getStringParameter, windowProfile, windowProfileEnd} from '@angular/testing/src/benchmark_util';
export const BENCHMARK_TYPE = 'LargetableComponent.benchmarkType';
export const LARGETABLE_ROWS = 'LargetableComponent.rows';
@ -110,8 +102,7 @@ export function main() {
function noop() {}
function initNg2() {
bootstrap(AppComponent, _createBindings())
.then((ref) => {
bootstrap(AppComponent, _createBindings()).then((ref) => {
var injector = ref.injector;
app = ref.instance;
appRef = injector.get(ApplicationRef);
@ -138,7 +129,8 @@ export function main() {
bindAction('#baselineCreateDom', baselineCreateDom);
bindAction('#baselineUpdateDomProfile', profile(baselineCreateDom, noop, 'baseline-update'));
bindAction('#baselineCreateDomProfile',
bindAction(
'#baselineCreateDomProfile',
profile(baselineCreateDom, baselineDestroyDom, 'baseline-create'));
}
@ -248,7 +240,8 @@ class LargetableComponent {
benchmarkType: string;
rows: number;
columns: number;
constructor(@Inject(BENCHMARK_TYPE) benchmarkType, @Inject(LARGETABLE_ROWS) rows,
constructor(
@Inject(BENCHMARK_TYPE) benchmarkType, @Inject(LARGETABLE_ROWS) rows,
@Inject(LARGETABLE_COLS) columns) {
this.benchmarkType = benchmarkType;
this.rows = rows;

View File

@ -1,12 +1,12 @@
import {isPresent} from '@angular/facade/src/lang';
import {getIntParameter, bindAction} from '@angular/testing/src/benchmark_util';
import {TimerWrapper} from '@angular/facade/src/async';
import {ScrollAreaComponent} from './scroll_area';
import {NgIf, NgFor} from '@angular/common';
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {document} from '@angular/facade/src/browser';
import {NgFor, NgIf} from '@angular/common';
import {Component, Directive} from '@angular/core';
import {TimerWrapper} from '@angular/facade/src/async';
import {document} from '@angular/facade/src/browser';
import {isPresent} from '@angular/facade/src/lang';
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {bindAction, getIntParameter} from '@angular/testing/src/benchmark_util';
import {ScrollAreaComponent} from './scroll_area';
@Component({

View File

@ -1,8 +1,8 @@
import {ListWrapper, Map} from '@angular/facade/src/collection';
import {Company, Opportunity, Offering, Account, CustomDate, STATUS_LIST} from './common';
import {NgFor} from '@angular/common';
import {Component, Directive} from '@angular/core';
import {ListWrapper, Map} from '@angular/facade/src/collection';
import {Account, Company, CustomDate, Offering, Opportunity, STATUS_LIST} from './common';
export class HasStyle {
cellWidth: number;

View File

@ -1,6 +1,6 @@
import {Math} from '@angular/facade/src/math';
import {StringWrapper} from '@angular/facade/src/lang';
import {ListWrapper, Map, MapWrapper} from '@angular/facade/src/collection';
import {StringWrapper} from '@angular/facade/src/lang';
import {Math} from '@angular/facade/src/math';
export var ITEMS = 1000;
export var ITEM_HEIGHT = 40;
@ -21,9 +21,8 @@ export var DUE_DATE_WIDTH = 100;
export var END_DATE_WIDTH = 100;
export var AAT_STATUS_WIDTH = 100;
export var ROW_WIDTH = COMPANY_NAME_WIDTH + OPPORTUNITY_NAME_WIDTH + OFFERING_NAME_WIDTH +
ACCOUNT_CELL_WIDTH + BASE_POINTS_WIDTH + KICKER_POINTS_WIDTH +
STAGE_BUTTONS_WIDTH + BUNDLES_WIDTH + DUE_DATE_WIDTH + END_DATE_WIDTH +
AAT_STATUS_WIDTH;
ACCOUNT_CELL_WIDTH + BASE_POINTS_WIDTH + KICKER_POINTS_WIDTH + STAGE_BUTTONS_WIDTH +
BUNDLES_WIDTH + DUE_DATE_WIDTH + END_DATE_WIDTH + AAT_STATUS_WIDTH;
export var STATUS_LIST = ['Planned', 'Pitched', 'Won', 'Lost'];

View File

@ -1,15 +1,10 @@
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {
NgModule
} from '@angular/core';
import {App} from './app';
@NgModule({
imports: [BrowserModule],
bootstrap: [App]
})
@NgModule({imports: [BrowserModule], bootstrap: [App]})
class AppModule {
}

View File

@ -1,13 +1,6 @@
import {StringWrapper} from '@angular/facade/src/lang';
import {
CustomDate,
Offering,
Company,
Opportunity,
Account,
STATUS_LIST,
AAT_STATUS_LIST
} from './common';
import {AAT_STATUS_LIST, Account, Company, CustomDate, Offering, Opportunity, STATUS_LIST} from './common';
export function generateOfferings(count: number): Offering[] {
var res = [];
@ -52,18 +45,7 @@ export function generateAccount(seed: number): Account {
}
var names = [
'Foo',
'Bar',
'Baz',
'Qux',
'Quux',
'Garply',
'Waldo',
'Fred',
'Plugh',
'Xyzzy',
'Thud',
'Cruft',
'Foo', 'Bar', 'Baz', 'Qux', 'Quux', 'Garply', 'Waldo', 'Fred', 'Plugh', 'Xyzzy', 'Thud', 'Cruft',
'Stuff'
];

View File

@ -1,20 +1,11 @@
import {NgFor} from '@angular/common';
import {Component, Directive} from '@angular/core';
import {ListWrapper} from '@angular/facade/src/collection';
import {Math} from '@angular/facade/src/math';
import {Component, Directive} from '@angular/core';
import {
Offering,
ITEMS,
ITEM_HEIGHT,
VISIBLE_ITEMS,
VIEW_PORT_HEIGHT,
ROW_WIDTH,
HEIGHT
} from './common';
import {HEIGHT, ITEMS, ITEM_HEIGHT, Offering, ROW_WIDTH, VIEW_PORT_HEIGHT, VISIBLE_ITEMS} from './common';
import {generateOfferings} from './random_data';
import {ScrollItemComponent} from './scroll_item';
import {NgFor} from '@angular/common';
@Component({
selector: 'scroll-area',

View File

@ -1,40 +1,14 @@
import {
CompanyNameComponent,
OpportunityNameComponent,
OfferingNameComponent,
StageButtonsComponent,
AccountCellComponent,
FormattedCellComponent
} from './cells';
import {Component, Directive} from '@angular/core';
import {
Offering,
ITEM_HEIGHT,
COMPANY_NAME_WIDTH,
OPPORTUNITY_NAME_WIDTH,
OFFERING_NAME_WIDTH,
ACCOUNT_CELL_WIDTH,
BASE_POINTS_WIDTH,
KICKER_POINTS_WIDTH,
STAGE_BUTTONS_WIDTH,
BUNDLES_WIDTH,
DUE_DATE_WIDTH,
END_DATE_WIDTH,
AAT_STATUS_WIDTH
} from './common';
import {AccountCellComponent, CompanyNameComponent, FormattedCellComponent, OfferingNameComponent, OpportunityNameComponent, StageButtonsComponent} from './cells';
import {AAT_STATUS_WIDTH, ACCOUNT_CELL_WIDTH, BASE_POINTS_WIDTH, BUNDLES_WIDTH, COMPANY_NAME_WIDTH, DUE_DATE_WIDTH, END_DATE_WIDTH, ITEM_HEIGHT, KICKER_POINTS_WIDTH, OFFERING_NAME_WIDTH, OPPORTUNITY_NAME_WIDTH, Offering, STAGE_BUTTONS_WIDTH} from './common';
@Component({
selector: 'scroll-item',
inputs: ['offering'],
directives: [
CompanyNameComponent,
OpportunityNameComponent,
OfferingNameComponent,
StageButtonsComponent,
AccountCellComponent,
FormattedCellComponent
CompanyNameComponent, OpportunityNameComponent, OfferingNameComponent, StageButtonsComponent,
AccountCellComponent, FormattedCellComponent
],
template: `
<div class="row"

View File

@ -1,6 +1,6 @@
import {Component, NgModule} from 'angular2/core';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {Component, NgModule} from 'angular2/core';
@Component({selector: 'app', template: '<h1>Page Load Time</h1>'})
class App {

View File

@ -3,18 +3,12 @@ import {Component, NgModule} from '@angular/core';
import {ApplicationRef} from '@angular/core/src/application_ref';
import {reflector} from '@angular/core/src/reflection/reflection';
import {ReflectionCapabilities} from '@angular/core/src/reflection/reflection_capabilities';
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {window, document, gc} from '@angular/facade/src/browser';
import {
getIntParameter,
getStringParameter,
bindAction,
windowProfile,
windowProfileEnd
} from '@angular/testing/src/benchmark_util';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {document, gc, window} from '@angular/facade/src/browser';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import {DOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {bindAction, getIntParameter, getStringParameter, windowProfile, windowProfileEnd} from '@angular/testing/src/benchmark_util';
function createBindings(): any[] {
return [];
@ -92,8 +86,7 @@ export function main() {
}
function initNg2() {
platformBrowserDynamic().bootstrapModule(AppModule)
.then((ref) => {
platformBrowserDynamic().bootstrapModule(AppModule).then((ref) => {
var injector = ref.injector;
appRef = injector.get(ApplicationRef);
@ -118,7 +111,8 @@ export function main() {
bindAction('#baselineCreateDom', baselineCreateDom);
bindAction('#baselineUpdateDomProfile', profile(baselineCreateDom, noop, 'baseline-update'));
bindAction('#baselineCreateDomProfile',
bindAction(
'#baselineCreateDomProfile',
profile(baselineCreateDom, baselineDestroyDom, 'baseline-create'));
}
@ -139,7 +133,8 @@ class TreeNode {
function buildTree(maxDepth, values, curDepth) {
if (maxDepth === curDepth) return new TreeNode('', null, null);
return new TreeNode(values[curDepth], buildTree(maxDepth, values, curDepth + 1),
return new TreeNode(
values[curDepth], buildTree(maxDepth, values, curDepth + 1),
buildTree(maxDepth, values, curDepth + 1));
}
@ -233,7 +228,8 @@ class StaticTreeComponent0 extends StaticTreeComponentBase {
selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent0],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
template:
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
})
class StaticTreeComponent1 extends StaticTreeComponentBase {
}
@ -242,7 +238,8 @@ class StaticTreeComponent1 extends StaticTreeComponentBase {
selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent1],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
template:
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
})
class StaticTreeComponent2 extends StaticTreeComponentBase {
data: TreeNode;
@ -252,7 +249,8 @@ class StaticTreeComponent2 extends StaticTreeComponentBase {
selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent2],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
template:
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
})
class StaticTreeComponent3 extends StaticTreeComponentBase {
}
@ -261,7 +259,8 @@ class StaticTreeComponent3 extends StaticTreeComponentBase {
selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent3],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
template:
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
})
class StaticTreeComponent4 extends StaticTreeComponentBase {
}
@ -270,7 +269,8 @@ class StaticTreeComponent4 extends StaticTreeComponentBase {
selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent4],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
template:
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
})
class StaticTreeComponent5 extends StaticTreeComponentBase {
}
@ -279,7 +279,8 @@ class StaticTreeComponent5 extends StaticTreeComponentBase {
selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent5],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
template:
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
})
class StaticTreeComponent6 extends StaticTreeComponentBase {
}
@ -288,7 +289,8 @@ class StaticTreeComponent6 extends StaticTreeComponentBase {
selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent6],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
template:
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
})
class StaticTreeComponent7 extends StaticTreeComponentBase {
}
@ -297,7 +299,8 @@ class StaticTreeComponent7 extends StaticTreeComponentBase {
selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent7],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
template:
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
})
class StaticTreeComponent8 extends StaticTreeComponentBase {
}
@ -306,7 +309,8 @@ class StaticTreeComponent8 extends StaticTreeComponentBase {
selector: 'tree',
inputs: ['data'],
directives: [StaticTreeComponent8],
template: `<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
template:
`<span> {{data.value}} <tree [data]='data.right'></tree><tree [data]='data.left'></tree></span>`
})
class StaticTreeComponent9 extends StaticTreeComponentBase {
}

View File

@ -1,12 +1,7 @@
import {
getIntParameter,
windowProfile,
windowProfileEnd
} from '@angular/platform-browser/testing/benchmark_util';
import {getIntParameter, windowProfile, windowProfileEnd} from '@angular/platform-browser/testing/benchmark_util';
export class TreeNode {
constructor(public value: string, public left: TreeNode, public right: TreeNode) {
}
constructor(public value: string, public left: TreeNode, public right: TreeNode) {}
}
let treeCreateCount: number;
@ -29,8 +24,8 @@ function init() {
function _buildTree(values: string[], curDepth: number = 0): TreeNode {
if (maxDepth === curDepth) return new TreeNode('', null, null);
return new TreeNode(values[curDepth], _buildTree(values, curDepth + 1),
_buildTree(values, curDepth + 1));
return new TreeNode(
values[curDepth], _buildTree(values, curDepth + 1), _buildTree(values, curDepth + 1));
}
export function emptyTree(): TreeNode {

View File

@ -4,7 +4,8 @@ import {TreeNode} from '../../app/util';
// http://jsperf.com/nextsibling-vs-childnodes
const BASELINE_TREE_TEMPLATE = document.createElement('template');
BASELINE_TREE_TEMPLATE.innerHTML = '<span>_<template class="ng-provider"></template><template class="ng-provider"></template></span>';
BASELINE_TREE_TEMPLATE.innerHTML =
'<span>_<template class="ng-provider"></template><template class="ng-provider"></template></span>';
const BASELINE_IF_TEMPLATE = document.createElement('template');
BASELINE_IF_TEMPLATE.innerHTML = '<span template="if"><tree></tree></span>';
@ -32,9 +33,7 @@ export class BaseLineTreeComponent {
export class BaseLineInterpolation {
value: string;
constructor(public textNode: Node) {
this.value = null;
}
constructor(public textNode: Node) { this.value = null; }
update(value: string) {
if (this.value !== value) {
this.value = value;

View File

@ -1,19 +1,16 @@
import {
bindAction
} from '@angular/platform-browser/testing/benchmark_util';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
import {bindAction} from '@angular/platform-browser/testing/benchmark_util';
import {TreeNode, buildTree, emptyTree, profile} from '../app/util';
import {BaseLineTreeComponent} from './app/tree';
import {TreeNode, buildTree, emptyTree, profile} from '../app/util';
import {BrowserDomAdapter} from '@angular/platform-browser/src/browser/browser_adapter';
export function main() {
var app: BaseLineTreeComponent;
function destroyDom() { app.update(emptyTree()); }
function createDom() {
app.update(buildTree());
}
function createDom() { app.update(buildTree()); }
function noop() {}
@ -27,8 +24,7 @@ export function main() {
bindAction('#createDom', createDom);
bindAction('#updateDomProfile', profile(createDom, noop, 'baseline-update'));
bindAction('#createDomProfile',
profile(createDom, destroyDom, 'baseline-create'));
bindAction('#createDomProfile', profile(createDom, destroyDom, 'baseline-create'));
}
init();

View File

@ -1,7 +1,4 @@
import {
Component,
NgModule
} from '@angular/core';
import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {TreeNode, emptyTree} from '../../app/util';
@ -16,13 +13,10 @@ class TreeComponent {
data: TreeNode;
}
@Component(
{selector: 'app', template: `<tree [data]='initData'></tree>`})
@Component({selector: 'app', template: `<tree [data]='initData'></tree>`})
export class AppComponent {
initData: TreeNode;
constructor() {
this.initData = emptyTree();
}
constructor() { this.initData = emptyTree(); }
}
@NgModule({
@ -30,4 +24,5 @@ export class AppComponent {
bootstrap: [AppComponent],
declarations: [TreeComponent, AppComponent]
})
export class AppModule {}
export class AppModule {
}

View File

@ -1,18 +1,11 @@
import {
NgModule,
enableProdMode
} from '@angular/core';
import {NgModule, enableProdMode} from '@angular/core';
import {ApplicationRef} from '@angular/core/src/application_ref';
import {
bindAction,
windowProfile,
windowProfileEnd
} from '@angular/platform-browser/testing/benchmark_util';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {bindAction, windowProfile, windowProfileEnd} from '@angular/platform-browser/testing/benchmark_util';
import {TreeNode, buildTree, emptyTree, profile} from '../app/util';
import {AppComponent, AppModule} from './app/tree';
import {TreeNode, buildTree, emptyTree, profile} from '../app/util';
export function main() {
var app: AppComponent;
@ -32,8 +25,7 @@ export function main() {
function init() {
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule)
.then((ref) => {
platformBrowserDynamic().bootstrapModule(AppModule).then((ref) => {
var injector = ref.injector;
appRef = injector.get(ApplicationRef);

View File

@ -11,7 +11,6 @@
</template>
</span>
</template>
</dom-module>
<script>
Polymer({
is: 'binary-tree',
@ -22,3 +21,4 @@
rightTree: null
});
</script>
</dom-module>

View File

@ -1,7 +1,6 @@
import {bindAction} from '@angular/platform-browser/testing/benchmark_util';
import {buildTree, emptyTree} from '../app/util';
import {
bindAction
} from '@angular/platform-browser/testing/benchmark_util';
declare var Polymer: any;
@ -9,13 +8,9 @@ export function main() {
const rootEl: any = document.querySelector('binary-tree');
rootEl.data = emptyTree();
function destroyDom() {
rootEl.data = emptyTree();
}
function destroyDom() { rootEl.data = emptyTree(); }
function createDom() {
rootEl.data = buildTree();
}
function createDom() { rootEl.data = buildTree(); }
bindAction('#destroyDom', destroyDom);
bindAction('#createDom', createDom);