2016-08-26 15:27:24 -04:00
|
|
|
/**
|
|
|
|
* @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
|
|
|
|
*/
|
2015-05-30 00:40:15 -04:00
|
|
|
|
2016-08-30 12:29:39 -04:00
|
|
|
import {runBenchmark, verifyNoBrowserErrors} from 'e2e_util/perf_util';
|
2017-04-13 18:00:59 -04:00
|
|
|
import {$, browser} from 'protractor';
|
2015-05-30 00:40:15 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
import {Benchmark, Benchmarks, CreateBtn, DestroyBtn, DetectChangesBtn, RootEl} from './tree_data';
|
2016-09-01 19:56:45 -04:00
|
|
|
|
2016-08-30 17:17:37 -04:00
|
|
|
describe('tree benchmark perf', () => {
|
2015-05-30 00:40:15 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
let _oldRootEl: any;
|
|
|
|
beforeEach(() => _oldRootEl = browser.rootEl);
|
2015-05-30 00:40:15 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
afterEach(() => {
|
|
|
|
browser.rootEl = _oldRootEl;
|
|
|
|
verifyNoBrowserErrors();
|
|
|
|
});
|
2016-09-30 12:09:31 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
Benchmarks.forEach(benchmark => {
|
|
|
|
describe(benchmark.id, () => {
|
|
|
|
it('should work for createOnly', (done) => {
|
2017-01-20 16:10:57 -05:00
|
|
|
runTreeBenchmark({
|
2017-04-13 18:00:59 -04:00
|
|
|
id: 'createOnly',
|
|
|
|
benchmark,
|
|
|
|
prepare: () => $(CreateBtn).click(),
|
|
|
|
work: () => $(DestroyBtn).click()
|
2017-01-20 16:10:57 -05:00
|
|
|
}).then(done, done.fail);
|
|
|
|
});
|
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
it('should work for createDestroy', (done) => {
|
2016-09-01 19:56:45 -04:00
|
|
|
runTreeBenchmark({
|
2017-04-13 18:00:59 -04:00
|
|
|
id: 'createDestroy',
|
|
|
|
benchmark,
|
|
|
|
work: () => {
|
|
|
|
$(DestroyBtn).click();
|
|
|
|
$(CreateBtn).click();
|
|
|
|
}
|
2016-09-30 12:09:31 -04:00
|
|
|
}).then(done, done.fail);
|
|
|
|
});
|
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
it('should work for update', (done) => {
|
|
|
|
runTreeBenchmark({id: 'update', benchmark, work: () => $(CreateBtn).click()})
|
|
|
|
.then(done, done.fail);
|
2016-09-01 19:56:45 -04:00
|
|
|
});
|
2016-09-01 13:31:31 -04:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
2016-09-01 13:31:31 -04:00
|
|
|
|
2016-09-01 19:56:45 -04:00
|
|
|
});
|
2017-01-20 16:10:57 -05:00
|
|
|
});
|
2017-04-13 18:00:59 -04:00
|
|
|
});
|
2016-12-28 18:26:49 -05:00
|
|
|
|
2017-04-13 18:00:59 -04:00
|
|
|
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);
|
2016-08-30 17:17:37 -04:00
|
|
|
}
|
2017-04-13 18:00:59 -04:00
|
|
|
browser.rootEl = RootEl;
|
|
|
|
return runBenchmark({
|
|
|
|
id: `${benchmark.id}.${id}`,
|
|
|
|
url: benchmark.url,
|
|
|
|
ignoreBrowserSynchronization: benchmark.ignoreBrowserSynchronization,
|
|
|
|
params: params,
|
|
|
|
work: work,
|
|
|
|
prepare: prepare,
|
|
|
|
setup: setup
|
|
|
|
});
|
|
|
|
}
|