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

@ -15,7 +15,7 @@ describe('ng2 compiler benchmark', function() {
afterEach(verifyNoBrowserErrors);
it('should log withBindings stats', function(done) {
it('should log withBindings stats', async() => {
browser.sleep(1000);
runBenchmark({
url: URL,
@ -25,10 +25,10 @@ describe('ng2 compiler benchmark', function() {
browser.executeScript('document.querySelector("#compileWithBindings").click()');
browser.sleep(500);
}
}).then(done, done.fail);
});
});
it('should log noBindings stats', function(done) {
it('should log noBindings stats', async() => {
browser.sleep(1000);
runBenchmark({
url: URL,
@ -38,7 +38,7 @@ describe('ng2 compiler benchmark', function() {
browser.executeScript('document.querySelector("#compileNoBindings").click()');
browser.sleep(500);
}
}).then(done, done.fail);
});
});
});

View File

@ -18,30 +18,30 @@ describe('ng2 cost benchmark', function() {
afterEach(verifyNoBrowserErrors);
it('should log stats for baseline (plain components)', function(done) {
it('should log stats for baseline (plain components)', async() => {
runClickBenchmark({
url: URL,
buttons: ['#reset', '#createPlainComponents'],
id: 'ng2.costs.baseline',
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
}).then(done, done.fail);
});
});
it('should log stats for components with decorators', function(done) {
it('should log stats for components with decorators', async() => {
runClickBenchmark({
url: URL,
buttons: ['#reset', '#createComponentsWithDirectives'],
id: 'ng2.costs.decorators',
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
}).then(done, done.fail);
});
});
it('should log stats for dynamic components', function(done) {
it('should log stats for dynamic components', async() => {
runClickBenchmark({
url: URL,
buttons: ['#reset', '#createDynamicComponents'],
id: 'ng2.costs.dynamic',
params: [{name: 'size', value: benchmarkSize, scale: 'linear'}]
}).then(done, done.fail);
});
});
});

View File

@ -15,7 +15,7 @@ describe('ng2 di benchmark', function() {
afterEach(verifyNoBrowserErrors);
it('should log the stats for getByToken', function(done) {
it('should log the stats for getByToken', async() => {
runClickBenchmark({
url: URL,
buttons: ['#getByToken'],
@ -23,10 +23,10 @@ describe('ng2 di benchmark', function() {
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
microMetrics: {'injectAvg': 'avg time for injection (in ms)'},
waitForAngular2: false
}).then(done, done.fail);
});
});
it('should log the stats for getByKey', function(done) {
it('should log the stats for getByKey', async() => {
runClickBenchmark({
url: URL,
buttons: ['#getByKey'],
@ -34,10 +34,10 @@ describe('ng2 di benchmark', function() {
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
microMetrics: {'injectAvg': 'avg time for injection (in ms)'},
waitForAngular2: false
}).then(done, done.fail);
});
});
it('should log the stats for getChild', function(done) {
it('should log the stats for getChild', async() => {
runClickBenchmark({
url: URL,
buttons: ['#getChild'],
@ -45,10 +45,10 @@ describe('ng2 di benchmark', function() {
params: [{name: 'iterations', value: 20000, scale: 'linear'}],
microMetrics: {'injectAvg': 'avg time for getChild (in ms)'},
waitForAngular2: false
}).then(done, done.fail);
});
});
it('should log the stats for instantiate', function(done) {
it('should log the stats for instantiate', async() => {
runClickBenchmark({
url: URL,
buttons: ['#instantiate'],
@ -56,14 +56,14 @@ describe('ng2 di benchmark', function() {
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
microMetrics: {'injectAvg': 'avg time for instantiate (in ms)'},
waitForAngular2: false
}).then(done, done.fail);
});
});
/**
* This benchmark measures the cost of creating a new injector with a mix
* of binding types: Type, unresolved, unflattened.
*/
it('should log the stats for createVariety', function(done) {
it('should log the stats for createVariety', async() => {
runClickBenchmark({
url: URL,
buttons: ['#createVariety'],
@ -71,13 +71,13 @@ describe('ng2 di benchmark', function() {
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
microMetrics: {'injectAvg': 'avg time for createVariety (in ms)'},
waitForAngular2: false
}).then(done, done.fail);
});
});
/**
* Same as 'createVariety' benchmark but operates on fully resolved bindings.
*/
it('should log the stats for createVarietyResolved', function(done) {
it('should log the stats for createVarietyResolved', async() => {
runClickBenchmark({
url: URL,
buttons: ['#createVarietyResolved'],
@ -85,7 +85,7 @@ describe('ng2 di benchmark', function() {
params: [{name: 'iterations', value: 10000, scale: 'linear'}],
microMetrics: {'injectAvg': 'avg time for createVarietyResolved (in ms)'},
waitForAngular2: false
}).then(done, done.fail);
});
});
});

View File

@ -23,7 +23,7 @@ describe('ng2 largetable benchmark', function() {
// 'interpolationFilter'
['interpolation', 'interpolationAttr', 'interpolationFn'].forEach(function(benchmarkType) {
it('should log the ng stats with: ' + benchmarkType, function(done) {
it('should log the ng stats with: ' + benchmarkType, async() => {
runClickBenchmark({
url: URL,
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
@ -32,11 +32,11 @@ describe('ng2 largetable benchmark', function() {
{name: 'rows', value: 20, scale: 'sqrt'}, {name: 'columns', value: 20, scale: 'sqrt'},
{name: 'benchmarkType', value: benchmarkType}
]
}).then(done, done.fail);
});
});
});
it('should log the baseline stats', function(done) {
it('should log the baseline stats', async() => {
runClickBenchmark({
url: URL,
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
@ -45,7 +45,7 @@ describe('ng2 largetable benchmark', function() {
{name: 'rows', value: 100, scale: 'sqrt'}, {name: 'columns', value: 20, scale: 'sqrt'},
{name: 'benchmarkType', value: 'baseline'}
]
}).then(done, done.fail);
});
});
});

View File

@ -16,7 +16,7 @@ describe('ng2 naive infinite scroll benchmark', function() {
afterEach(verifyNoBrowserErrors);
[1, 2, 4].forEach(function(appSize) {
it('should run scroll benchmark and collect stats for appSize = ' + appSize, function(done) {
it('should run scroll benchmark and collect stats for appSize = ' + appSize, async() => {
runBenchmark({
url: URL,
id: 'ng2.naive_infinite_scroll',
@ -31,7 +31,7 @@ describe('ng2 naive infinite scroll benchmark', function() {
{name: 'appSize', value: appSize}, {name: 'iterationCount', value: 20, scale: 'linear'},
{name: 'scrollIncrement', value: 40}
]
}).then(done, done.fail);
});
});
});

View File

@ -15,7 +15,7 @@ describe('ng2 naive infinite scroll benchmark', function() {
afterEach(verifyNoBrowserErrors);
it('should not throw errors', function() {
it('should not throw errors', async() => {
browser.get(URL);
const expectedRowCount = 18;
const expectedCellsPerRow = 27;

View File

@ -16,7 +16,7 @@ describe('ng2 largetable benchmark', function() {
afterEach(verifyNoBrowserErrors);
it('should log the load time', function(done) {
it('should log the load time', async() => {
runner
.sample({
id: 'loadTime',

View File

@ -15,34 +15,34 @@ describe('ng2 selector benchmark', function() {
afterEach(verifyNoBrowserErrors);
it('should log parse stats', function(done) {
it('should log parse stats', async() => {
runClickBenchmark({
url: URL,
buttons: ['#parse'],
id: 'ng2.selector.parse',
params: [{name: 'selectors', value: 10000, scale: 'linear'}],
waitForAngular2: false
}).then(done, done.fail);
});
});
it('should log addSelectable stats', function(done) {
it('should log addSelectable stats', async() => {
runClickBenchmark({
url: URL,
buttons: ['#addSelectable'],
id: 'ng2.selector.addSelectable',
params: [{name: 'selectors', value: 10000, scale: 'linear'}],
waitForAngular2: false
}).then(done, done.fail);
});
});
it('should log match stats', function(done) {
it('should log match stats', async() => {
runClickBenchmark({
url: URL,
buttons: ['#match'],
id: 'ng2.selector.match',
params: [{name: 'selectors', value: 10000, scale: 'linear'}],
waitForAngular2: false
}).then(done, done.fail);
});
});
});

View File

@ -15,34 +15,34 @@ describe('ng2 static tree benchmark', function() {
afterEach(verifyNoBrowserErrors);
it('should log the ng stats', function(done) {
it('should log the ng stats', async() => {
runClickBenchmark({
url: URL,
buttons: ['#ng2DestroyDom', '#ng2CreateDom'],
id: 'ng2.static.tree.create.plain',
params: []
}).then(done, done.fail);
});
});
it('should log the ng stats (update)', function(done) {
it('should log the ng stats (update)', async() => {
runClickBenchmark(
{url: URL, buttons: ['#ng2CreateDom'], id: 'ng2.static.tree.update', params: []})
.then(done, done.fail);
;
});
it('should log the baseline stats', function(done) {
it('should log the baseline stats', async() => {
runClickBenchmark({
url: URL,
buttons: ['#baselineDestroyDom', '#baselineCreateDom'],
id: 'baseline.static.tree.create',
params: []
}).then(done, done.fail);
});
});
it('should log the baseline stats (update)', function(done) {
it('should log the baseline stats (update)', async() => {
runClickBenchmark(
{url: URL, buttons: ['#baselineCreateDom'], id: 'baseline.static.tree.update', params: []})
.then(done, done.fail);
;
});
});

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');