parent
							
								
									61002733bc
								
							
						
					
					
						commit
						c377e80670
					
				| @ -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); | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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)) | ||||
|  | ||||
| @ -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<els.length; i++) { | ||||
|       for (var i = 0; i < els.length; i++) { | ||||
|         el = els[i]; | ||||
|         if (el.type === 'radio' || el.type === 'checkbox') { | ||||
|           el.checked = el.value === value; | ||||
|  | ||||
| @ -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,27 +18,28 @@ 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) => { | ||||
|         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) { | ||||
|  | ||||
| @ -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(); | ||||
|  | ||||
| @ -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 { | ||||
| } | ||||
| @ -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)); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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({ | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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']; | ||||
| 
 | ||||
|  | ||||
| @ -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 { | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -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' | ||||
| ]; | ||||
| 
 | ||||
|  | ||||
| @ -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', | ||||
|  | ||||
| @ -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" | ||||
|  | ||||
| @ -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 { | ||||
|  | ||||
| @ -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: `<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 { | ||||
| } | ||||
|  | ||||
| @ -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<maxDepth; i++) { | ||||
|   for (let i = 0; i < maxDepth; i++) { | ||||
|     numberData.push(i.toString()); | ||||
|     charData.push(String.fromCharCode('A'.charCodeAt(0) + i)); | ||||
|   } | ||||
| @ -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 { | ||||
| @ -43,30 +38,30 @@ export function buildTree(): TreeNode { | ||||
| } | ||||
| 
 | ||||
| export function profile(create: () => void, destroy: () => void, name: string) { | ||||
|     return function() { | ||||
|       windowProfile(name + ' w GC'); | ||||
|       var duration = 0; | ||||
|       var count = 0; | ||||
|       while (count++ < 150) { | ||||
|         (<any>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) { | ||||
|       (<any>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`); | ||||
|     }; | ||||
|   } | ||||
|     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`); | ||||
|   }; | ||||
| } | ||||
| @ -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 = '<span>_<template class="ng-provider"></template><template class="ng-provider"></template></span>'; | ||||
| const BASELINE_IF_TEMPLATE =document.createElement('template'); | ||||
| const BASELINE_TREE_TEMPLATE = document.createElement('template'); | ||||
| 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>'; | ||||
| 
 | ||||
| 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; | ||||
|  | ||||
| @ -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(); | ||||
|  | ||||
| @ -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 { | ||||
| } | ||||
|  | ||||
| @ -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(); | ||||
|  | ||||
| @ -11,14 +11,14 @@ | ||||
|       </template> | ||||
|     </span> | ||||
|   </template> | ||||
|   <script> | ||||
|     Polymer({ | ||||
|       is: 'binary-tree', | ||||
|       properties: { | ||||
|         data: Object | ||||
|       }, | ||||
|       leftTree: null, | ||||
|       rightTree: null | ||||
|     }); | ||||
|   </script> | ||||
| </dom-module> | ||||
| <script> | ||||
|   Polymer({ | ||||
|     is: 'binary-tree', | ||||
|     properties: { | ||||
|       data: Object | ||||
|     }, | ||||
|     leftTree: null, | ||||
|     rightTree: null | ||||
|   }); | ||||
| </script> | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user