
committed by
Miško Hevery

parent
95bb72d322
commit
018507fa02
@ -1,79 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {$} from 'protractor';
|
||||
|
||||
export const CreateBtn = '#createDom';
|
||||
export const DestroyBtn = '#destroyDom';
|
||||
export const DetectChangesBtn = '#detectChanges';
|
||||
export const RootEl = '#root';
|
||||
export const NumberOfChecksEl = '#numberOfChecks';
|
||||
|
||||
export interface Benchmark {
|
||||
id: string;
|
||||
url: string;
|
||||
buttons: string[];
|
||||
ignoreBrowserSynchronization?: boolean;
|
||||
extraParams?: {name: string, value: any}[];
|
||||
}
|
||||
|
||||
const CreateDestroyButtons: string[] = [CreateBtn, DestroyBtn];
|
||||
const CreateDestroyDetectChangesButtons: string[] = [...CreateDestroyButtons, DetectChangesBtn];
|
||||
|
||||
export const Benchmarks: Benchmark[] = [
|
||||
{
|
||||
id: `deepTree.ng2`,
|
||||
url: 'all/benchmarks/src/tree/ng2/index.html',
|
||||
buttons: CreateDestroyDetectChangesButtons,
|
||||
},
|
||||
{
|
||||
id: `deepTree.ng2.next`,
|
||||
url: 'all/benchmarks/src/tree/ng2_next/index.html',
|
||||
buttons: CreateDestroyDetectChangesButtons,
|
||||
ignoreBrowserSynchronization: true,
|
||||
},
|
||||
{
|
||||
id: `deepTree.ng2.static`,
|
||||
url: 'all/benchmarks/src/tree/ng2_static/index.html',
|
||||
buttons: CreateDestroyButtons,
|
||||
},
|
||||
{
|
||||
id: `deepTree.ng2_switch`,
|
||||
url: 'all/benchmarks/src/tree/ng2_switch/index.html',
|
||||
buttons: CreateDestroyButtons,
|
||||
},
|
||||
{
|
||||
id: `deepTree.ng2.render3_function`,
|
||||
url: 'all/benchmarks/src/tree/render3_function/index.html',
|
||||
buttons: CreateDestroyDetectChangesButtons,
|
||||
ignoreBrowserSynchronization: true,
|
||||
},
|
||||
{
|
||||
id: `deepTree.iv`,
|
||||
url: 'all/benchmarks/src/tree/iv/index.html',
|
||||
buttons: CreateDestroyDetectChangesButtons,
|
||||
ignoreBrowserSynchronization: true,
|
||||
},
|
||||
{
|
||||
id: `deepTree.baseline`,
|
||||
url: 'all/benchmarks/src/tree/baseline/index.html',
|
||||
buttons: CreateDestroyButtons,
|
||||
ignoreBrowserSynchronization: true,
|
||||
},
|
||||
{
|
||||
id: `deepTree.incremental_dom`,
|
||||
url: 'all/benchmarks/src/tree/incremental_dom/index.html',
|
||||
buttons: CreateDestroyButtons,
|
||||
ignoreBrowserSynchronization: true,
|
||||
},
|
||||
{
|
||||
id: `deepTree.ng1`,
|
||||
url: 'all/benchmarks/src/tree/ng1/index.html',
|
||||
buttons: CreateDestroyDetectChangesButtons,
|
||||
}
|
||||
];
|
@ -1,93 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {runBenchmark, verifyNoBrowserErrors} from 'e2e_util/perf_util';
|
||||
import {$, browser} from 'protractor';
|
||||
|
||||
import {Benchmark, Benchmarks, CreateBtn, DestroyBtn, DetectChangesBtn, RootEl} from './tree_data';
|
||||
|
||||
describe('tree benchmark perf', () => {
|
||||
|
||||
let _oldRootEl: any;
|
||||
beforeEach(() => _oldRootEl = browser.rootEl);
|
||||
|
||||
afterEach(() => {
|
||||
browser.rootEl = _oldRootEl;
|
||||
verifyNoBrowserErrors();
|
||||
});
|
||||
|
||||
Benchmarks.forEach(benchmark => {
|
||||
describe(benchmark.id, () => {
|
||||
// This is actually a destroyOnly benchmark
|
||||
it('should work for createOnly', done => {
|
||||
runTreeBenchmark({
|
||||
id: 'createOnly',
|
||||
benchmark,
|
||||
prepare: () => $(CreateBtn).click(),
|
||||
work: () => $(DestroyBtn).click()
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should work for createOnlyForReal', done => {
|
||||
runTreeBenchmark({
|
||||
id: 'createOnlyForReal',
|
||||
benchmark,
|
||||
prepare: () => $(DestroyBtn).click(),
|
||||
work: () => $(CreateBtn).click()
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should work for createDestroy', done => {
|
||||
runTreeBenchmark({
|
||||
id: 'createDestroy',
|
||||
benchmark,
|
||||
work: () => {
|
||||
$(DestroyBtn).click();
|
||||
$(CreateBtn).click();
|
||||
}
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
|
||||
it('should work for update', done => {
|
||||
runTreeBenchmark({id: 'update', benchmark, work: () => $(CreateBtn).click()})
|
||||
.then(done, done.fail);
|
||||
});
|
||||
|
||||
if (benchmark.buttons.indexOf(DetectChangesBtn) !== -1) {
|
||||
it('should work for detectChanges', done => {
|
||||
runTreeBenchmark({
|
||||
id: 'detectChanges',
|
||||
benchmark,
|
||||
work: () => $(DetectChangesBtn).click(),
|
||||
setup: () => $(DestroyBtn).click()
|
||||
}).then(done, done.fail);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function runTreeBenchmark({id, benchmark, prepare, setup, work}: {
|
||||
id: string; benchmark: Benchmark, prepare ? () : void; setup ? () : void; work(): void;
|
||||
}) {
|
||||
let params = [{name: 'depth', value: 11}];
|
||||
if (benchmark.extraParams) {
|
||||
params = params.concat(benchmark.extraParams);
|
||||
}
|
||||
browser.rootEl = RootEl;
|
||||
return runBenchmark({
|
||||
id: `${benchmark.id}.${id}`,
|
||||
url: benchmark.url,
|
||||
ignoreBrowserSynchronization: benchmark.ignoreBrowserSynchronization,
|
||||
params: params,
|
||||
work: work,
|
||||
prepare: prepare,
|
||||
setup: setup
|
||||
});
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {openBrowser, verifyNoBrowserErrors} from 'e2e_util/e2e_util';
|
||||
import {$, browser} from 'protractor';
|
||||
|
||||
import {Benchmark, Benchmarks, CreateBtn, DestroyBtn, DetectChangesBtn, NumberOfChecksEl, RootEl} from './tree_data';
|
||||
|
||||
describe('tree benchmark spec', () => {
|
||||
|
||||
let _oldRootEl: any;
|
||||
beforeEach(() => _oldRootEl = browser.rootEl);
|
||||
|
||||
afterEach(() => {
|
||||
browser.rootEl = _oldRootEl;
|
||||
verifyNoBrowserErrors();
|
||||
});
|
||||
|
||||
Benchmarks.forEach(benchmark => {
|
||||
describe(benchmark.id, () => {
|
||||
it('should work for createDestroy', () => {
|
||||
openTreeBenchmark(benchmark);
|
||||
$(CreateBtn).click();
|
||||
expect($(RootEl).getText()).toContain('0');
|
||||
$(DestroyBtn).click();
|
||||
expect($(RootEl).getText()).toEqual('');
|
||||
});
|
||||
|
||||
it('should work for update', () => {
|
||||
openTreeBenchmark(benchmark);
|
||||
$(CreateBtn).click();
|
||||
$(CreateBtn).click();
|
||||
expect($(RootEl).getText()).toContain('A');
|
||||
});
|
||||
|
||||
if (benchmark.buttons.indexOf(DetectChangesBtn) !== -1) {
|
||||
it('should work for detectChanges', () => {
|
||||
openTreeBenchmark(benchmark);
|
||||
$(DetectChangesBtn).click();
|
||||
expect($(NumberOfChecksEl).getText()).toContain('10');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function openTreeBenchmark(benchmark: Benchmark) {
|
||||
let params = [{name: 'depth', value: 4}];
|
||||
if (benchmark.extraParams) {
|
||||
params = params.concat(benchmark.extraParams);
|
||||
}
|
||||
browser.rootEl = RootEl;
|
||||
openBrowser({
|
||||
url: benchmark.url,
|
||||
ignoreBrowserSynchronization: benchmark.ignoreBrowserSynchronization,
|
||||
params: params,
|
||||
});
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user