build: convert largeform benchmarks to bazel (#28645)

Switches the `largeform` benchmarks to Bazel.
This is the last remaining e2e test within `modules/`.

PR Close #28645
This commit is contained in:
Paul Gschwendtner 2019-02-11 21:04:06 +01:00 committed by Miško Hevery
parent 13685131bc
commit 0a4811c4ad
10 changed files with 94 additions and 60 deletions

View File

@ -2,6 +2,7 @@ package(default_visibility = ["//visibility:public"])
exports_files([
"tsconfig-build.json",
"tsconfig-e2e.json",
"start-server.js",
])

View File

@ -1,35 +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 {$, By, element} from 'protractor';
describe('largeform benchmark spec', () => {
afterEach(verifyNoBrowserErrors);
it('should work for ng2', () => {
testLargeformBenchmark({
url: 'all/benchmarks/src/largeform/ng2/index.html',
});
});
function testLargeformBenchmark(
openConfig: {url: string, ignoreBrowserSynchronization?: boolean}) {
openBrowser({
url: openConfig.url,
params: [{name: 'copies', value: 1}],
ignoreBrowserSynchronization: openConfig.ignoreBrowserSynchronization,
});
$('#createDom').click();
expect(element.all(By.css('input[name=value0]')).get(0).getAttribute('value'))
.toBe('someValue0');
$('#destroyDom').click();
expect(element.all(By.css('input[name=value0]')).count()).toBe(0);
}
});

View File

@ -0,0 +1,15 @@
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
load("//tools:defaults.bzl", "ts_library")
ts_library(
name = "tests_lib",
testonly = 1,
srcs = ["largeform_perf.spec.ts"],
tsconfig = "//modules/benchmarks:tsconfig-e2e.json",
deps = [
"//modules/e2e_util",
"@ngdeps//@types/jasminewd2",
"@ngdeps//protractor",
],
)

View File

@ -6,8 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/
import {runBenchmark, verifyNoBrowserErrors} from 'e2e_util/perf_util';
import {$} from 'protractor';
import {$, By, element} from 'protractor';
import {openBrowser, verifyNoBrowserErrors} from '../../../e2e_util/e2e_util';
import {runBenchmark} from '../../../e2e_util/perf_util';
interface Worker {
id: string;
@ -15,7 +17,7 @@ interface Worker {
work(): void;
}
const CreateAndDestroyWorker: Worker = {
const CreateAndDestroyWorker = {
id: 'createDestroy',
work: () => {
$('#createDom').click();
@ -23,18 +25,28 @@ const CreateAndDestroyWorker: Worker = {
}
};
describe('largeform benchmark perf', () => {
describe('largeform benchmark spec', () => {
afterEach(verifyNoBrowserErrors);
it('should work for ng2', () => {
openBrowser({
url: '/',
params: [{name: 'copies', value: 1}],
ignoreBrowserSynchronization: true,
});
$('#createDom').click();
expect(element.all(By.css('input[name=value0]')).get(0).getAttribute('value'))
.toBe('someValue0');
$('#destroyDom').click();
expect(element.all(By.css('input[name=value0]')).count()).toBe(0);
});
[CreateAndDestroyWorker].forEach((worker) => {
describe(worker.id, () => {
it('should run for ng2', done => {
runLargeFormBenchmark({
id: `largeform.ng2.${worker.id}`,
url: 'all/benchmarks/src/largeform/ng2/index.html',
worker: worker
}).then(done, done.fail);
runLargeFormBenchmark({url: '/', id: `largeform.ng2.${worker.id}`, worker: worker})
.then(done, done.fail);
});
});
});

View File

@ -0,0 +1,45 @@
load("//tools:defaults.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
# Note that this benchmark has been designed for Angular with ViewEngine, but once ViewEngine is
# removed, we should keep this benchmark and run it with Ivy (potentially rename it to "render3")
ng_module(
name = "ng2",
srcs = glob(["*.ts"]),
# FIXME-IVY(FW-998): ExpressionTranslatorVisitor#visitWriteKeyExpr is not implemented.
tags = ["fixme-ivy-aot"],
tsconfig = "//modules/benchmarks:tsconfig-build.json",
# TODO: FW-1004 Type checking is currently not complete.
type_check = False,
deps = [
"//modules/benchmarks/src:util_lib",
"//packages/core",
"//packages/forms",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
],
)
ts_devserver(
name = "devserver",
entry_module = "angular/modules/benchmarks/src/largeform/ng2/index",
index_html = "index.html",
port = 4200,
scripts = ["@ngdeps//node_modules/tslib:tslib.js"],
static_files = [
"@ngdeps//node_modules/zone.js:dist/zone.js",
"@ngdeps//node_modules/reflect-metadata:Reflect.js",
],
tags = ["fixme-ivy-aot"],
deps = [":ng2"],
)
benchmark_test(
name = "perf",
server = ":devserver",
tags = ["fixme-ivy-aot"],
deps = ["//modules/benchmarks/src/largeform:tests_lib"],
)

View File

@ -19,11 +19,5 @@
<div>
<app id="root">Loading...</app>
</div>
<script>
var mainUrl = window.location.search.split(/[?&]main=([^&]+)/)[1]
|| '../../bootstrap_ng2.js';
document.write('<script src="' + mainUrl + '">\u003c/script>');
</script>
</body>
</html>

View File

@ -12,7 +12,5 @@ import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app';
import {init} from './init';
export function main() {
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule).then(init);
}
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule).then(init);

View File

@ -4,6 +4,9 @@ load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
# Note that this benchmark has been designed for Angular with ViewEngine, but once
# ViewEngine is removed, we should should consider removing this one since there
# already is a "render3" benchmark.
ng_module(
name = "ng2",
srcs = glob(["*.ts"]),

View File

@ -0,0 +1,6 @@
{
"compilerOptions": {
"lib": ["es2015"],
"types": ["node", "jasminewd2"]
}
}

View File

@ -24,15 +24,10 @@
},
"exclude": [
"angular1_router",
"benchmarks/e2e_test/old",
"benchmarks/src/old",
"benchmarks/src/**/index_aot.ts",
"benchmarks_external",
"payload_tests",
// Tests which are already migrated to Bazel:
"playground/",
"benchmarks/src/largetable",
"benchmarks/src/tree"
"benchmarks/"
],
"angularCompilerOptions": {
"skipTemplateCodegen": true