refactor(benchpress): made all it callbacks async (#35147)

PR Close #35147
This commit is contained in:
Wagner Maciel
2020-02-04 13:53:57 -08:00
committed by Kara Erickson
parent 26b17aee14
commit 5ca7c2d40f
19 changed files with 80 additions and 81 deletions

View File

@ -11,7 +11,7 @@ import {runBenchmark} from '../../../e2e_util/perf_util';
describe('class bindings perf', () => {
it('should work for update', done => {
it('should work for update', async() => {
browser.rootEl = '#root';
runBenchmark({
id: 'create',
@ -20,10 +20,10 @@ describe('class bindings perf', () => {
params: [],
prepare: () => $('#destroy').click(),
work: () => $('#create').click()
}).then(done, done.fail);
});
});
it('should work for update', done => {
it('should work for update', async() => {
browser.rootEl = '#root';
runBenchmark({
id: 'update',
@ -32,7 +32,7 @@ describe('class bindings perf', () => {
params: [],
prepare: () => $('#create').click(),
work: () => $('#update').click()
}).then(done, done.fail);
});
});
});

View File

@ -11,7 +11,7 @@ import {runBenchmark} from '../../../e2e_util/perf_util';
describe('benchmarks', () => {
it('should work for create', done => {
it('should work for create', async() => {
browser.rootEl = '#root';
runBenchmark({
id: 'create',
@ -20,7 +20,7 @@ describe('benchmarks', () => {
params: [],
prepare: () => $('#reset').click(),
work: () => $('#init').click()
}).then(done, done.fail);
});
});
});

View File

@ -53,13 +53,13 @@ describe('js-web-frameworks benchmark perf', () => {
[Create1KWorker, Delete1KWorker, UpdateWorker, SwapWorker].forEach((worker) => {
describe(worker.id, () => {
it(`should run benchmark for ${testPackageName}`, done => {
it(`should run benchmark for ${testPackageName}`, async() => {
runTableBenchmark({
id: `js-web-frameworks.${testPackageName}.${worker.id}`,
url: '/',
ignoreBrowserSynchronization: true,
worker: worker
}).then(done, done.fail);
});
});
});
});

View File

@ -31,9 +31,8 @@ describe('largeform benchmark spec', () => {
[CreateAndDestroyWorker].forEach((worker) => {
describe(worker.id, () => {
it('should run for ng2', done => {
runLargeFormBenchmark({url: '/', id: `largeform.ng2.${worker.id}`, worker: worker})
.then(done, done.fail);
it('should run for ng2', async() => {
await runLargeFormBenchmark({url: '/', id: `largeform.ng2.${worker.id}`, worker: worker});
});
});
});

View File

@ -13,17 +13,17 @@ import {openBrowser, verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
describe('largetable benchmark', () => {
afterEach(verifyNoBrowserErrors);
it(`should render the table`, () => {
it(`should render the table`, async() => {
openBrowser({
url: '',
ignoreBrowserSynchronization: true,
params: [{name: 'cols', value: 5}, {name: 'rows', value: 5}],
});
$('#createDom').click();
await $('#createDom').click();
expect($('#root').getText()).toContain('0/0');
$('#createDom').click();
await $('#createDom').click();
expect($('#root').getText()).toContain('A/A');
$('#destroyDom').click();
await $('#destroyDom').click();
expect($('#root').getText() as any).toEqual('');
});
});

View File

@ -48,13 +48,13 @@ describe('largetable benchmark perf', () => {
[CreateOnlyWorker, CreateAndDestroyWorker, UpdateWorker].forEach((worker) => {
describe(worker.id, () => {
it(`should run benchmark for ${testPackageName}`, done => {
it(`should run benchmark for ${testPackageName}`, async() => {
runTableBenchmark({
id: `largeTable.${testPackageName}.${worker.id}`,
url: '/',
ignoreBrowserSynchronization: true,
worker: worker
}).then(done, done.fail);
});
});
});
});

View File

@ -51,34 +51,34 @@ describe('styling benchmark spec', () => {
// Create benchmarks for each possible test scenario.
SCENARIOS.forEach(({optionIndex, id}) => {
describe(id, () => {
it('should run create benchmark', done => {
runStylingBenchmark(`styling.${id}.create`, {
it('should run create benchmark', async() => {
await runStylingBenchmark(`styling.${id}.create`, {
work: () => create(),
prepare: () => {
selectScenario(optionIndex);
destroy();
},
}).then(done, done.fail);
});
});
it('should run update benchmark', done => {
runStylingBenchmark(`styling.${id}.update`, {
it('should run update benchmark', async() => {
await runStylingBenchmark(`styling.${id}.update`, {
work: () => update(),
prepare: () => {
selectScenario(optionIndex);
create();
},
}).then(done, done.fail);
});
});
it('should run detect changes benchmark', done => {
runStylingBenchmark(`styling.${id}.noop_cd`, {
it('should run detect changes benchmark', async() => {
await runStylingBenchmark(`styling.${id}.noop_cd`, {
work: () => detectChanges(),
prepare: () => {
selectScenario(optionIndex);
create();
},
}).then(done, done.fail);
});
});
});
});

View File

@ -11,7 +11,7 @@ import {$} from 'protractor';
import {openTreeBenchmark} from './test_utils';
describe('tree benchmark', () => {
it('should work for createDestroy', () => {
it('should work for createDestroy', async() => {
openTreeBenchmark();
$('#createDom').click();
expect($('#root').getText()).toContain('1');
@ -19,7 +19,7 @@ describe('tree benchmark', () => {
expect($('#root').getText() as any).toEqual('');
});
it('should work for update', () => {
it('should work for update', async() => {
openTreeBenchmark();
$('#createDom').click();
$('#createDom').click();

View File

@ -10,37 +10,37 @@ import {$} from 'protractor';
import {runTreeBenchmark} from './test_utils';
describe('tree benchmark perf', () => {
it('should work for createOnly', done => {
it('should work for createOnly', async() => {
runTreeBenchmark({
// This cannot be called "createOnly" because the actual destroy benchmark
// has the "createOnly" id already. See: https://github.com/angular/angular/pull/21503
id: 'createOnlyForReal',
prepare: () => $('#destroyDom').click(),
work: () => $('#createDom').click()
}).then(done, done.fail);
});
});
it('should work for destroy', done => {
it('should work for destroy', async() => {
runTreeBenchmark({
// This is actually a benchmark for destroying the dom, but it has been accidentally
// named "createOnly". See https://github.com/angular/angular/pull/21503.
id: 'createOnly',
prepare: () => $('#createDom').click(),
work: () => $('#destroyDom').click()
}).then(done, done.fail);
});
});
it('should work for createDestroy', done => {
it('should work for createDestroy', async() => {
runTreeBenchmark({
id: 'createDestroy',
work: () => {
$('#destroyDom').click();
$('#createDom').click();
}
}).then(done, done.fail);
});
});
it('should work for update', done => {
runTreeBenchmark({id: 'update', work: () => $('#createDom').click()}).then(done, done.fail);
it('should work for update', async() => {
runTreeBenchmark({id: 'update', work: () => $('#createDom').click()});
});
});

View File

@ -11,7 +11,7 @@ import {$} from 'protractor';
import {openTreeBenchmark} from './test_utils';
describe('tree benchmark detect changes', () => {
it('should work for detectChanges', () => {
it('should work for detectChanges', async() => {
openTreeBenchmark();
$('#detectChanges').click();
expect($('#numberOfChecks').getText()).toContain('10');