From c377e806703ec4fe45c15c95027ed7529309402b Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Fri, 26 Aug 2016 15:44:05 -0700 Subject: [PATCH] chore: format benchmarks closes #11112 --- .../old/naive_infinite_scroll_perf.ts | 7 +- .../old/naive_infinite_scroll_spec.ts | 31 ++++---- .../benchmarks/e2e_test/old/page_load_perf.ts | 28 ++++---- modules/benchmarks/src/bootstrap.ts | 4 +- .../src/old/compiler/compiler_benchmark.ts | 38 +++++----- .../src/old/compiler/selector_benchmark.ts | 4 +- modules/benchmarks/src/old/costs/index.ts | 60 ++++++++-------- modules/benchmarks/src/old/di/di_benchmark.ts | 7 +- .../old/largetable/largetable_benchmark.ts | 51 ++++++------- .../src/old/naive_infinite_scroll/app.ts | 16 ++--- .../src/old/naive_infinite_scroll/cells.ts | 6 +- .../src/old/naive_infinite_scroll/common.ts | 9 ++- .../src/old/naive_infinite_scroll/index.ts | 9 +-- .../old/naive_infinite_scroll/random_data.ts | 24 +------ .../old/naive_infinite_scroll/scroll_area.ts | 15 +--- .../old/naive_infinite_scroll/scroll_item.ts | 34 ++------- .../benchmarks/src/old/page_load/page_load.ts | 2 +- .../src/old/static_tree/tree_benchmark.ts | 72 ++++++++++--------- modules/benchmarks/src/tree/app/util.ts | 67 ++++++++--------- .../benchmarks/src/tree/baseline/app/tree.ts | 11 ++- modules/benchmarks/src/tree/baseline/index.ts | 16 ++--- modules/benchmarks/src/tree/ng2/app/tree.ts | 15 ++-- modules/benchmarks/src/tree/ng2/index.ts | 34 ++++----- .../src/tree/polymer/binary_tree.html | 20 +++--- modules/benchmarks/src/tree/polymer/index.ts | 13 ++-- 25 files changed, 248 insertions(+), 345 deletions(-) diff --git a/modules/benchmarks/e2e_test/old/naive_infinite_scroll_perf.ts b/modules/benchmarks/e2e_test/old/naive_infinite_scroll_perf.ts index 2170fc3e14..77b834043e 100644 --- a/modules/benchmarks/e2e_test/old/naive_infinite_scroll_perf.ts +++ b/modules/benchmarks/e2e_test/old/naive_infinite_scroll_perf.ts @@ -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); diff --git a/modules/benchmarks/e2e_test/old/naive_infinite_scroll_spec.ts b/modules/benchmarks/e2e_test/old/naive_infinite_scroll_spec.ts index c6eb405228..d05d9359eb 100644 --- a/modules/benchmarks/e2e_test/old/naive_infinite_scroll_spec.ts +++ b/modules/benchmarks/e2e_test/old/naive_infinite_scroll_spec.ts @@ -16,8 +16,9 @@ describe('ng2 naive infinite scroll benchmark', function() { var stageButtons = `${ allScrollItems } .row stage-buttons button`; var count = function(selector) { - return browser.executeScript(`return ` + - `document.querySelectorAll("${ selector }").length;`); + return browser.executeScript( + `return ` + + `document.querySelectorAll("${ selector }").length;`); }; var clickFirstOf = function(selector) { @@ -25,8 +26,9 @@ describe('ng2 naive infinite scroll benchmark', function() { }; var firstTextOf = function(selector) { - return browser.executeScript(`return ` + - `document.querySelector("${ selector }").innerText;`); + return browser.executeScript( + `return ` + + `document.querySelector("${ selector }").innerText;`); }; // Make sure rows are rendered @@ -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) { - expect(text).toEqual('Pitched'); - clickFirstOf(`${ stageButtons }:enabled`) - .then(function() { - firstTextOf(`${ stageButtons }:enabled`) - .then(function(text) { expect(text).toEqual('Won'); }) - }); - }); + 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'); + }) + }); + }); - $("#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); diff --git a/modules/benchmarks/e2e_test/old/page_load_perf.ts b/modules/benchmarks/e2e_test/old/page_load_perf.ts index b3aba2fb22..878e095e46 100644 --- a/modules/benchmarks/e2e_test/old/page_load_perf.ts +++ b/modules/benchmarks/e2e_test/old/page_load_perf.ts @@ -9,20 +9,20 @@ describe('ng2 largetable benchmark', function() { it('should log the load time', function(done) { - 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.RegressionSlopeValidator.SAMPLE_SIZE).toValue(2), - benchpress.bind(benchpress.RegressionSlopeValidator.METRIC).toValue('someConstant') - ], - execute: () => { browser.get(URL); } - }) + 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.RegressionSlopeValidator.SAMPLE_SIZE).toValue(2), + benchpress.bind(benchpress.RegressionSlopeValidator.METRIC).toValue('someConstant') + ], + execute: () => { browser.get(URL); } + }) .then(report => { expect(report.completeSample.map(val => val.values.someConstant) .every(v => v === 1234567890)) diff --git a/modules/benchmarks/src/bootstrap.ts b/modules/benchmarks/src/bootstrap.ts index f0162c938d..f5cc16cc12 100644 --- a/modules/benchmarks/src/bootstrap.ts +++ b/modules/benchmarks/src/bootstrap.ts @@ -93,9 +93,9 @@ while (match = regex.exec(search)) { var name = match[1]; var value = match[2]; - var els = document.querySelectorAll('input[name="'+name+'"]'); + var els = document.querySelectorAll('input[name="' + name + '"]'); var el: any; - for (var i=0; i 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) => { - var app = ref.instance; - bindAction('#compileNoBindings', - measureWrapper(() => app.compileNoBindings(), 'No Bindings')); - bindAction('#compileWithBindings', - measureWrapper(() => app.compileWithBindings(), 'With Bindings')); - }); + bootstrap(CompilerAppComponent, _createBindings()).then((ref) => { + var app = ref.instance; + bindAction('#compileNoBindings', measureWrapper(() => app.compileNoBindings(), 'No Bindings')); + bindAction( + '#compileWithBindings', measureWrapper(() => app.compileWithBindings(), 'With Bindings')); + }); } function measureWrapper(func, desc) { diff --git a/modules/benchmarks/src/old/compiler/selector_benchmark.ts b/modules/benchmarks/src/old/compiler/selector_benchmark.ts index b6b71f5f84..77c840741f 100644 --- a/modules/benchmarks/src/old/compiler/selector_benchmark.ts +++ b/modules/benchmarks/src/old/compiler/selector_benchmark.ts @@ -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(); diff --git a/modules/benchmarks/src/old/costs/index.ts b/modules/benchmarks/src/old/costs/index.ts index ff295d9b19..be86043de6 100644 --- a/modules/benchmarks/src/old/costs/index.ts +++ b/modules/benchmarks/src/old/costs/index.ts @@ -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,35 +13,34 @@ export function main() { var size = getIntParameter('size'); testList = ListWrapper.createFixedSize(size); - platformBrowserDynamic().bootstrapModule(AppModule) - .then((ref) => { - var injector = ref.injector; - var app: AppComponent = ref.instance; - var appRef = injector.get(ApplicationRef); + platformBrowserDynamic().bootstrapModule(AppModule).then((ref) => { + var injector = ref.injector; + var app: AppComponent = ref.instance; + var appRef = injector.get(ApplicationRef); - bindAction('#reset', function() { - app.reset(); - appRef.tick(); - }); + bindAction('#reset', function() { + app.reset(); + appRef.tick(); + }); - // Baseline (plain components) - bindAction('#createPlainComponents', function() { - app.createPlainComponents(); - appRef.tick(); - }); + // Baseline (plain components) + bindAction('#createPlainComponents', function() { + app.createPlainComponents(); + appRef.tick(); + }); - // Components with decorators - bindAction('#createComponentsWithDirectives', function() { - app.createComponentsWithDirectives(); - appRef.tick(); - }); + // Components with decorators + bindAction('#createComponentsWithDirectives', function() { + app.createComponentsWithDirectives(); + appRef.tick(); + }); - // Components with decorators - bindAction('#createDynamicComponents', function() { - app.createDynamicComponents(); - appRef.tick(); - }); - }); + // Components with decorators + bindAction('#createDynamicComponents', function() { + app.createDynamicComponents(); + appRef.tick(); + }); + }); } @@ -110,9 +109,6 @@ class AppComponent { -@NgModule({ - imports: [BrowserModule], - bootstrap: [AppComponent] -}) +@NgModule({imports: [BrowserModule], bootstrap: [AppComponent]}) class AppModule { } \ No newline at end of file diff --git a/modules/benchmarks/src/old/di/di_benchmark.ts b/modules/benchmarks/src/old/di/di_benchmark.ts index 0ab3fc708a..3fa18b851d 100644 --- a/modules/benchmarks/src/old/di/di_benchmark.ts +++ b/modules/benchmarks/src/old/di/di_benchmark.ts @@ -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,8 +81,9 @@ export function main() { bindAction('#getChild', () => microBenchmark('injectAvg', iterations, getChild)); bindAction('#instantiate', () => microBenchmark('injectAvg', iterations, instantiate)); bindAction('#createVariety', () => microBenchmark('injectAvg', iterations, createVariety)); - bindAction('#createVarietyResolved', - () => microBenchmark('injectAvg', iterations, createVarietyResolved)); + bindAction( + '#createVarietyResolved', + () => microBenchmark('injectAvg', iterations, createVarietyResolved)); } diff --git a/modules/benchmarks/src/old/largetable/largetable_benchmark.ts b/modules/benchmarks/src/old/largetable/largetable_benchmark.ts index 137bc390a2..c632d09315 100644 --- a/modules/benchmarks/src/old/largetable/largetable_benchmark.ts +++ b/modules/benchmarks/src/old/largetable/largetable_benchmark.ts @@ -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,16 +102,15 @@ export function main() { function noop() {} function initNg2() { - bootstrap(AppComponent, _createBindings()) - .then((ref) => { - var injector = ref.injector; - app = ref.instance; - appRef = injector.get(ApplicationRef); - bindAction('#ng2DestroyDom', ng2DestroyDom); - bindAction('#ng2CreateDom', ng2CreateDom); - bindAction('#ng2UpdateDomProfile', profile(ng2CreateDom, noop, 'ng2-update')); - bindAction('#ng2CreateDomProfile', profile(ng2CreateDom, ng2DestroyDom, 'ng2-create')); - }); + bootstrap(AppComponent, _createBindings()).then((ref) => { + var injector = ref.injector; + app = ref.instance; + appRef = injector.get(ApplicationRef); + bindAction('#ng2DestroyDom', ng2DestroyDom); + bindAction('#ng2CreateDom', ng2CreateDom); + bindAction('#ng2UpdateDomProfile', profile(ng2CreateDom, noop, 'ng2-update')); + bindAction('#ng2CreateDomProfile', profile(ng2CreateDom, ng2DestroyDom, 'ng2-create')); + }); setupReflector(); } @@ -138,8 +129,9 @@ export function main() { bindAction('#baselineCreateDom', baselineCreateDom); bindAction('#baselineUpdateDomProfile', profile(baselineCreateDom, noop, 'baseline-update')); - bindAction('#baselineCreateDomProfile', - profile(baselineCreateDom, baselineDestroyDom, 'baseline-create')); + bindAction( + '#baselineCreateDomProfile', + profile(baselineCreateDom, baselineDestroyDom, 'baseline-create')); } initNg2(); @@ -248,8 +240,9 @@ class LargetableComponent { benchmarkType: string; rows: number; columns: number; - constructor(@Inject(BENCHMARK_TYPE) benchmarkType, @Inject(LARGETABLE_ROWS) rows, - @Inject(LARGETABLE_COLS) columns) { + constructor( + @Inject(BENCHMARK_TYPE) benchmarkType, @Inject(LARGETABLE_ROWS) rows, + @Inject(LARGETABLE_COLS) columns) { this.benchmarkType = benchmarkType; this.rows = rows; this.columns = columns; diff --git a/modules/benchmarks/src/old/naive_infinite_scroll/app.ts b/modules/benchmarks/src/old/naive_infinite_scroll/app.ts index 91fd9c2679..de1fefb110 100644 --- a/modules/benchmarks/src/old/naive_infinite_scroll/app.ts +++ b/modules/benchmarks/src/old/naive_infinite_scroll/app.ts @@ -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({ diff --git a/modules/benchmarks/src/old/naive_infinite_scroll/cells.ts b/modules/benchmarks/src/old/naive_infinite_scroll/cells.ts index 0d1303a7cd..aa3ae7a476 100644 --- a/modules/benchmarks/src/old/naive_infinite_scroll/cells.ts +++ b/modules/benchmarks/src/old/naive_infinite_scroll/cells.ts @@ -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; diff --git a/modules/benchmarks/src/old/naive_infinite_scroll/common.ts b/modules/benchmarks/src/old/naive_infinite_scroll/common.ts index 0b7703f515..3e6a5bd235 100644 --- a/modules/benchmarks/src/old/naive_infinite_scroll/common.ts +++ b/modules/benchmarks/src/old/naive_infinite_scroll/common.ts @@ -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']; diff --git a/modules/benchmarks/src/old/naive_infinite_scroll/index.ts b/modules/benchmarks/src/old/naive_infinite_scroll/index.ts index 441214fe0a..ec8a2244cb 100644 --- a/modules/benchmarks/src/old/naive_infinite_scroll/index.ts +++ b/modules/benchmarks/src/old/naive_infinite_scroll/index.ts @@ -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 { } diff --git a/modules/benchmarks/src/old/naive_infinite_scroll/random_data.ts b/modules/benchmarks/src/old/naive_infinite_scroll/random_data.ts index bb1e3db0e0..be931f1e01 100644 --- a/modules/benchmarks/src/old/naive_infinite_scroll/random_data.ts +++ b/modules/benchmarks/src/old/naive_infinite_scroll/random_data.ts @@ -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' ]; diff --git a/modules/benchmarks/src/old/naive_infinite_scroll/scroll_area.ts b/modules/benchmarks/src/old/naive_infinite_scroll/scroll_area.ts index d245b97d68..9b9f9274f2 100644 --- a/modules/benchmarks/src/old/naive_infinite_scroll/scroll_area.ts +++ b/modules/benchmarks/src/old/naive_infinite_scroll/scroll_area.ts @@ -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', diff --git a/modules/benchmarks/src/old/naive_infinite_scroll/scroll_item.ts b/modules/benchmarks/src/old/naive_infinite_scroll/scroll_item.ts index 0ee9fd91b7..3e866b75a0 100644 --- a/modules/benchmarks/src/old/naive_infinite_scroll/scroll_item.ts +++ b/modules/benchmarks/src/old/naive_infinite_scroll/scroll_item.ts @@ -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: `
Page Load Time'}) class App { diff --git a/modules/benchmarks/src/old/static_tree/tree_benchmark.ts b/modules/benchmarks/src/old/static_tree/tree_benchmark.ts index 24d84e8b37..39768072a1 100644 --- a/modules/benchmarks/src/old/static_tree/tree_benchmark.ts +++ b/modules/benchmarks/src/old/static_tree/tree_benchmark.ts @@ -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,17 +86,16 @@ export function main() { } function initNg2() { - platformBrowserDynamic().bootstrapModule(AppModule) - .then((ref) => { - var injector = ref.injector; - appRef = injector.get(ApplicationRef); + platformBrowserDynamic().bootstrapModule(AppModule).then((ref) => { + var injector = ref.injector; + appRef = injector.get(ApplicationRef); - app = ref.instance; - bindAction('#ng2DestroyDom', ng2DestroyDom); - bindAction('#ng2CreateDom', ng2CreateDom); - bindAction('#ng2UpdateDomProfile', profile(ng2CreateDom, noop, 'ng2-update')); - bindAction('#ng2CreateDomProfile', profile(ng2CreateDom, ng2DestroyDom, 'ng2-create')); - }); + app = ref.instance; + bindAction('#ng2DestroyDom', ng2DestroyDom); + bindAction('#ng2CreateDom', ng2CreateDom); + bindAction('#ng2UpdateDomProfile', profile(ng2CreateDom, noop, 'ng2-update')); + bindAction('#ng2CreateDomProfile', profile(ng2CreateDom, ng2DestroyDom, 'ng2-create')); + }); } function baselineDestroyDom() { baselineRootTreeComponent.update(null); } @@ -118,8 +111,9 @@ export function main() { bindAction('#baselineCreateDom', baselineCreateDom); bindAction('#baselineUpdateDomProfile', profile(baselineCreateDom, noop, 'baseline-update')); - bindAction('#baselineCreateDomProfile', - profile(baselineCreateDom, baselineDestroyDom, 'baseline-create')); + bindAction( + '#baselineCreateDomProfile', + profile(baselineCreateDom, baselineDestroyDom, 'baseline-create')); } initNg2(); @@ -139,8 +133,9 @@ 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), - buildTree(maxDepth, values, curDepth + 1)); + return new TreeNode( + values[curDepth], buildTree(maxDepth, values, curDepth + 1), + buildTree(maxDepth, values, curDepth + 1)); } // http://jsperf.com/nextsibling-vs-childnodes @@ -233,7 +228,8 @@ class StaticTreeComponent0 extends StaticTreeComponentBase { selector: 'tree', inputs: ['data'], directives: [StaticTreeComponent0], - template: ` {{data.value}} ` + template: + ` {{data.value}} ` }) class StaticTreeComponent1 extends StaticTreeComponentBase { } @@ -242,7 +238,8 @@ class StaticTreeComponent1 extends StaticTreeComponentBase { selector: 'tree', inputs: ['data'], directives: [StaticTreeComponent1], - template: ` {{data.value}} ` + template: + ` {{data.value}} ` }) class StaticTreeComponent2 extends StaticTreeComponentBase { data: TreeNode; @@ -252,7 +249,8 @@ class StaticTreeComponent2 extends StaticTreeComponentBase { selector: 'tree', inputs: ['data'], directives: [StaticTreeComponent2], - template: ` {{data.value}} ` + template: + ` {{data.value}} ` }) class StaticTreeComponent3 extends StaticTreeComponentBase { } @@ -261,7 +259,8 @@ class StaticTreeComponent3 extends StaticTreeComponentBase { selector: 'tree', inputs: ['data'], directives: [StaticTreeComponent3], - template: ` {{data.value}} ` + template: + ` {{data.value}} ` }) class StaticTreeComponent4 extends StaticTreeComponentBase { } @@ -270,7 +269,8 @@ class StaticTreeComponent4 extends StaticTreeComponentBase { selector: 'tree', inputs: ['data'], directives: [StaticTreeComponent4], - template: ` {{data.value}} ` + template: + ` {{data.value}} ` }) class StaticTreeComponent5 extends StaticTreeComponentBase { } @@ -279,7 +279,8 @@ class StaticTreeComponent5 extends StaticTreeComponentBase { selector: 'tree', inputs: ['data'], directives: [StaticTreeComponent5], - template: ` {{data.value}} ` + template: + ` {{data.value}} ` }) class StaticTreeComponent6 extends StaticTreeComponentBase { } @@ -288,7 +289,8 @@ class StaticTreeComponent6 extends StaticTreeComponentBase { selector: 'tree', inputs: ['data'], directives: [StaticTreeComponent6], - template: ` {{data.value}} ` + template: + ` {{data.value}} ` }) class StaticTreeComponent7 extends StaticTreeComponentBase { } @@ -297,7 +299,8 @@ class StaticTreeComponent7 extends StaticTreeComponentBase { selector: 'tree', inputs: ['data'], directives: [StaticTreeComponent7], - template: ` {{data.value}} ` + template: + ` {{data.value}} ` }) class StaticTreeComponent8 extends StaticTreeComponentBase { } @@ -306,7 +309,8 @@ class StaticTreeComponent8 extends StaticTreeComponentBase { selector: 'tree', inputs: ['data'], directives: [StaticTreeComponent8], - template: ` {{data.value}} ` + template: + ` {{data.value}} ` }) class StaticTreeComponent9 extends StaticTreeComponentBase { } diff --git a/modules/benchmarks/src/tree/app/util.ts b/modules/benchmarks/src/tree/app/util.ts index 396e43e8fb..5d39f432d8 100644 --- a/modules/benchmarks/src/tree/app/util.ts +++ b/modules/benchmarks/src/tree/app/util.ts @@ -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; @@ -21,7 +16,7 @@ function init() { treeCreateCount = 0; numberData = []; charData = []; - for (let i = 0; i void, destroy: () => void, name: string) { - return function() { - windowProfile(name + ' w GC'); - var duration = 0; - var count = 0; - while (count++ < 150) { - (window)['gc'](); - var start = window.performance.now(); - create(); - duration += window.performance.now() - start; - destroy(); - } - windowProfileEnd(name + ' w GC'); - window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`); + return function() { + windowProfile(name + ' w GC'); + var duration = 0; + var count = 0; + while (count++ < 150) { + (window)['gc'](); + var start = window.performance.now(); + create(); + duration += window.performance.now() - start; + destroy(); + } + windowProfileEnd(name + ' w GC'); + window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`); - windowProfile(name + ' w/o GC'); - duration = 0; - count = 0; - while (count++ < 150) { - var start = window.performance.now(); - create(); - duration += window.performance.now() - start; - destroy(); - } - windowProfileEnd(name + ' w/o GC'); - window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`); - }; - } \ No newline at end of file + windowProfile(name + ' w/o GC'); + duration = 0; + count = 0; + while (count++ < 150) { + var start = window.performance.now(); + create(); + duration += window.performance.now() - start; + destroy(); + } + windowProfileEnd(name + ' w/o GC'); + window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`); + }; +} \ No newline at end of file diff --git a/modules/benchmarks/src/tree/baseline/app/tree.ts b/modules/benchmarks/src/tree/baseline/app/tree.ts index 5013909f0d..28800df07d 100644 --- a/modules/benchmarks/src/tree/baseline/app/tree.ts +++ b/modules/benchmarks/src/tree/baseline/app/tree.ts @@ -3,9 +3,10 @@ import {TreeNode} from '../../app/util'; // http://jsperf.com/nextsibling-vs-childnodes -const BASELINE_TREE_TEMPLATE =document.createElement('template'); -BASELINE_TREE_TEMPLATE.innerHTML = '_'; -const BASELINE_IF_TEMPLATE =document.createElement('template'); +const BASELINE_TREE_TEMPLATE = document.createElement('template'); +BASELINE_TREE_TEMPLATE.innerHTML = + '_'; +const BASELINE_IF_TEMPLATE = document.createElement('template'); BASELINE_IF_TEMPLATE.innerHTML = ''; export class BaseLineTreeComponent { @@ -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; diff --git a/modules/benchmarks/src/tree/baseline/index.ts b/modules/benchmarks/src/tree/baseline/index.ts index 315077c9fb..c82eb4025f 100644 --- a/modules/benchmarks/src/tree/baseline/index.ts +++ b/modules/benchmarks/src/tree/baseline/index.ts @@ -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(); diff --git a/modules/benchmarks/src/tree/ng2/app/tree.ts b/modules/benchmarks/src/tree/ng2/app/tree.ts index 8141dfce1e..5a8506ac2e 100644 --- a/modules/benchmarks/src/tree/ng2/app/tree.ts +++ b/modules/benchmarks/src/tree/ng2/app/tree.ts @@ -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: ``}) +@Component({selector: 'app', template: ``}) 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 { +} diff --git a/modules/benchmarks/src/tree/ng2/index.ts b/modules/benchmarks/src/tree/ng2/index.ts index fc9abcc6a7..c47a8ea5ca 100644 --- a/modules/benchmarks/src/tree/ng2/index.ts +++ b/modules/benchmarks/src/tree/ng2/index.ts @@ -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,17 +25,16 @@ export function main() { function init() { enableProdMode(); - platformBrowserDynamic().bootstrapModule(AppModule) - .then((ref) => { - var injector = ref.injector; - appRef = injector.get(ApplicationRef); + platformBrowserDynamic().bootstrapModule(AppModule).then((ref) => { + var injector = ref.injector; + appRef = injector.get(ApplicationRef); - app = appRef.components[0].instance; - bindAction('#destroyDom', destroyDom); - bindAction('#createDom', createDom); - bindAction('#updateDomProfile', profile(createDom, noop, 'ng2-update')); - bindAction('#createDomProfile', profile(createDom, destroyDom, 'ng2-create')); - }); + app = appRef.components[0].instance; + bindAction('#destroyDom', destroyDom); + bindAction('#createDom', createDom); + bindAction('#updateDomProfile', profile(createDom, noop, 'ng2-update')); + bindAction('#createDomProfile', profile(createDom, destroyDom, 'ng2-create')); + }); } init(); diff --git a/modules/benchmarks/src/tree/polymer/binary_tree.html b/modules/benchmarks/src/tree/polymer/binary_tree.html index 7c924a686a..d1fe165bb7 100644 --- a/modules/benchmarks/src/tree/polymer/binary_tree.html +++ b/modules/benchmarks/src/tree/polymer/binary_tree.html @@ -11,14 +11,14 @@ + - diff --git a/modules/benchmarks/src/tree/polymer/index.ts b/modules/benchmarks/src/tree/polymer/index.ts index e19f413213..a4e53525c0 100644 --- a/modules/benchmarks/src/tree/polymer/index.ts +++ b/modules/benchmarks/src/tree/polymer/index.ts @@ -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);