build: run largetable benchmark tests with bazel (#28645)
PR Close #28645
This commit is contained in:
parent
1a326d5690
commit
13685131bc
@ -1,99 +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 {$} from 'protractor';
|
|
||||||
|
|
||||||
interface Worker {
|
|
||||||
id: string;
|
|
||||||
prepare?(): void;
|
|
||||||
work(): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CreateOnlyWorker: Worker = {
|
|
||||||
id: 'createOnly',
|
|
||||||
prepare: () => $('#destroyDom').click(),
|
|
||||||
work: () => $('#createDom').click()
|
|
||||||
};
|
|
||||||
|
|
||||||
const CreateAndDestroyWorker: Worker = {
|
|
||||||
id: 'createDestroy',
|
|
||||||
work: () => {
|
|
||||||
$('#createDom').click();
|
|
||||||
$('#destroyDom').click();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const UpdateWorker: Worker = {
|
|
||||||
id: 'update',
|
|
||||||
work: () => $('#createDom').click()
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('largetable benchmark perf', () => {
|
|
||||||
|
|
||||||
afterEach(verifyNoBrowserErrors);
|
|
||||||
|
|
||||||
[CreateOnlyWorker, CreateAndDestroyWorker, UpdateWorker].forEach((worker) => {
|
|
||||||
describe(worker.id, () => {
|
|
||||||
it('should run for ng2', done => {
|
|
||||||
runTableBenchmark({
|
|
||||||
id: `largeTable.ng2.${worker.id}`,
|
|
||||||
url: 'all/benchmarks/src/largetable/ng2/index.html',
|
|
||||||
worker: worker
|
|
||||||
}).then(done, done.fail);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should run for ng2 with ngSwitch', done => {
|
|
||||||
runTableBenchmark({
|
|
||||||
id: `largeTable.ng2_switch.${worker.id}`,
|
|
||||||
url: 'all/benchmarks/src/largetable/ng2_switch/index.html',
|
|
||||||
worker: worker
|
|
||||||
}).then(done, done.fail);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should run for iv', done => {
|
|
||||||
runTableBenchmark({
|
|
||||||
id: `largeTable.iv.${worker.id}`,
|
|
||||||
url: 'all/benchmarks/src/largetable/iv/index.html',
|
|
||||||
ignoreBrowserSynchronization: true,
|
|
||||||
worker: worker
|
|
||||||
}).then(done, done.fail);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should run for the baseline', done => {
|
|
||||||
runTableBenchmark({
|
|
||||||
id: `largeTable.baseline.${worker.id}`,
|
|
||||||
url: 'all/benchmarks/src/largetable/baseline/index.html',
|
|
||||||
ignoreBrowserSynchronization: true,
|
|
||||||
worker: worker
|
|
||||||
}).then(done, done.fail);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should run for incremental-dom', done => {
|
|
||||||
runTableBenchmark({
|
|
||||||
id: `largeTable.incremental_dom.${worker.id}`,
|
|
||||||
url: 'all/benchmarks/src/largetable/incremental_dom/index.html',
|
|
||||||
ignoreBrowserSynchronization: true,
|
|
||||||
worker: worker
|
|
||||||
}).then(done, done.fail);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function runTableBenchmark(
|
|
||||||
config: {id: string, url: string, ignoreBrowserSynchronization?: boolean, worker: Worker}) {
|
|
||||||
return runBenchmark({
|
|
||||||
id: config.id,
|
|
||||||
url: config.url,
|
|
||||||
ignoreBrowserSynchronization: config.ignoreBrowserSynchronization,
|
|
||||||
params: [{name: 'cols', value: 40}, {name: 'rows', value: 200}],
|
|
||||||
prepare: config.worker.prepare,
|
|
||||||
work: config.worker.work
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,62 +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 {$} from 'protractor';
|
|
||||||
|
|
||||||
describe('largetable benchmark spec', () => {
|
|
||||||
|
|
||||||
afterEach(verifyNoBrowserErrors);
|
|
||||||
|
|
||||||
it('should work for ng2', () => {
|
|
||||||
testTableBenchmark({
|
|
||||||
url: 'all/benchmarks/src/largetable/ng2/index.html',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work for ng2 switch', () => {
|
|
||||||
testTableBenchmark({
|
|
||||||
url: 'all/benchmarks/src/largetable/ng2_switch/index.html',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work for iv', () => {
|
|
||||||
testTableBenchmark({
|
|
||||||
url: 'all/benchmarks/src/largetable/iv/index.html',
|
|
||||||
ignoreBrowserSynchronization: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work for the baseline', () => {
|
|
||||||
testTableBenchmark({
|
|
||||||
url: 'all/benchmarks/src/largetable/baseline/index.html',
|
|
||||||
ignoreBrowserSynchronization: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work for the incremental-dom', () => {
|
|
||||||
testTableBenchmark({
|
|
||||||
url: 'all/benchmarks/src/largetable/incremental_dom/index.html',
|
|
||||||
ignoreBrowserSynchronization: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function testTableBenchmark(openConfig: {url: string, ignoreBrowserSynchronization?: boolean}) {
|
|
||||||
openBrowser({
|
|
||||||
url: openConfig.url,
|
|
||||||
ignoreBrowserSynchronization: openConfig.ignoreBrowserSynchronization,
|
|
||||||
params: [{name: 'cols', value: 5}, {name: 'rows', value: 5}],
|
|
||||||
});
|
|
||||||
$('#createDom').click();
|
|
||||||
expect($('#root').getText()).toContain('0/0');
|
|
||||||
$('#createDom').click();
|
|
||||||
expect($('#root').getText()).toContain('A/A');
|
|
||||||
$('#destroyDom').click();
|
|
||||||
expect($('#root').getText()).toEqual('');
|
|
||||||
}
|
|
||||||
});
|
|
@ -11,12 +11,9 @@ ts_library(
|
|||||||
ts_library(
|
ts_library(
|
||||||
name = "perf_lib",
|
name = "perf_lib",
|
||||||
testonly = 1,
|
testonly = 1,
|
||||||
srcs = [
|
srcs = ["largetable_perf.spec.ts"],
|
||||||
"largetable_perf.spec.ts",
|
|
||||||
],
|
|
||||||
deps = [
|
deps = [
|
||||||
"//modules/e2e_util",
|
"//modules/e2e_util",
|
||||||
"//packages:types",
|
|
||||||
"@ngdeps//protractor",
|
"@ngdeps//protractor",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
load("//tools:defaults.bzl", "ts_library")
|
load("//tools:defaults.bzl", "ts_library")
|
||||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
||||||
|
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
|
||||||
|
|
||||||
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
|
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
|
||||||
|
|
||||||
@ -20,3 +21,9 @@ ts_devserver(
|
|||||||
port = 4200,
|
port = 4200,
|
||||||
deps = [":baseline"],
|
deps = [":baseline"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
benchmark_test(
|
||||||
|
name = "perf",
|
||||||
|
server = ":devserver",
|
||||||
|
deps = ["//modules/benchmarks/src/largetable:perf_lib"],
|
||||||
|
)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
load("//tools:defaults.bzl", "ts_library")
|
load("//tools:defaults.bzl", "ts_library")
|
||||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
||||||
|
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
|
||||||
|
|
||||||
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
|
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
|
||||||
|
|
||||||
@ -23,3 +24,9 @@ ts_devserver(
|
|||||||
],
|
],
|
||||||
deps = [":incremental_dom"],
|
deps = [":incremental_dom"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
benchmark_test(
|
||||||
|
name = "perf",
|
||||||
|
server = ":devserver",
|
||||||
|
deps = ["//modules/benchmarks/src/largetable:perf_lib"],
|
||||||
|
)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
load("//tools:defaults.bzl", "ts_library")
|
load("//tools:defaults.bzl", "ts_library")
|
||||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
||||||
|
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
|
||||||
|
|
||||||
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
|
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
|
||||||
|
|
||||||
@ -9,3 +10,9 @@ ts_devserver(
|
|||||||
port = 4200,
|
port = 4200,
|
||||||
static_files = ["largetable.js"],
|
static_files = ["largetable.js"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
benchmark_test(
|
||||||
|
name = "perf",
|
||||||
|
server = ":devserver",
|
||||||
|
deps = ["//modules/benchmarks/src/largetable:perf_lib"],
|
||||||
|
)
|
||||||
|
@ -36,11 +36,19 @@ const UpdateWorker: Worker = {
|
|||||||
work: () => $('#createDom').click()
|
work: () => $('#createDom').click()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// In order to make sure that we don't change the ids of the benchmarks, we need to
|
||||||
|
// determine the current test package name from the Bazel target. This is necessary
|
||||||
|
// because previous to the Bazel conversion, the benchmark test ids contained the test
|
||||||
|
// name. e.g. "largeTable.ng2_switch.createDestroy". We determine the name of the
|
||||||
|
// Bazel package where this test runs from the current test target. The Bazel target
|
||||||
|
// looks like: "//modules/benchmarks/src/largetable/{pkg_name}:{target_name}".
|
||||||
|
const testPackageName = process.env['BAZEL_TARGET'] !.split(':')[0].split('/').pop();
|
||||||
|
|
||||||
describe('largetable benchmark perf', () => {
|
describe('largetable benchmark perf', () => {
|
||||||
|
|
||||||
afterEach(verifyNoBrowserErrors);
|
afterEach(verifyNoBrowserErrors);
|
||||||
|
|
||||||
it('should render the table for render3', () => {
|
it(`should render the table for ${testPackageName}`, () => {
|
||||||
openBrowser({
|
openBrowser({
|
||||||
url: '',
|
url: '',
|
||||||
ignoreBrowserSynchronization: true,
|
ignoreBrowserSynchronization: true,
|
||||||
@ -56,18 +64,19 @@ describe('largetable benchmark perf', () => {
|
|||||||
|
|
||||||
[CreateOnlyWorker, CreateAndDestroyWorker, UpdateWorker].forEach((worker) => {
|
[CreateOnlyWorker, CreateAndDestroyWorker, UpdateWorker].forEach((worker) => {
|
||||||
describe(worker.id, () => {
|
describe(worker.id, () => {
|
||||||
it('should run benchmark for render3', done => {
|
it(`should run benchmark for ${testPackageName}`, done => {
|
||||||
runTableBenchmark({
|
runTableBenchmark({
|
||||||
id: `largeTable.render3.${worker.id}`,
|
id: `largeTable.${testPackageName}.${worker.id}`,
|
||||||
url: 'index.html',
|
url: '/',
|
||||||
ignoreBrowserSynchronization: true,
|
ignoreBrowserSynchronization: true,
|
||||||
worker: worker
|
worker: worker
|
||||||
}).then(done, done.fail);
|
}).then(done, done.fail);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function runTableBenchmark(
|
function runTableBenchmark(
|
||||||
config: {id: string, url: string, ignoreBrowserSynchronization?: boolean, worker: Worker}) {
|
config: {id: string, url: string, ignoreBrowserSynchronization?: boolean, worker: Worker}) {
|
||||||
return runBenchmark({
|
return runBenchmark({
|
||||||
id: config.id,
|
id: config.id,
|
||||||
@ -77,5 +86,4 @@ describe('largetable benchmark perf', () => {
|
|||||||
prepare: config.worker.prepare,
|
prepare: config.worker.prepare,
|
||||||
work: config.worker.work
|
work: config.worker.work
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
load("//tools:defaults.bzl", "ng_module")
|
load("//tools:defaults.bzl", "ng_module")
|
||||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
||||||
|
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
|
||||||
|
|
||||||
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
|
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
|
||||||
|
|
||||||
@ -33,3 +34,9 @@ ts_devserver(
|
|||||||
],
|
],
|
||||||
deps = [":ng2"],
|
deps = [":ng2"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
benchmark_test(
|
||||||
|
name = "perf",
|
||||||
|
server = ":devserver",
|
||||||
|
deps = ["//modules/benchmarks/src/largetable:perf_lib"],
|
||||||
|
)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
load("//tools:defaults.bzl", "ng_module")
|
load("//tools:defaults.bzl", "ng_module")
|
||||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
||||||
|
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
|
||||||
|
|
||||||
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
|
package(default_visibility = ["//modules/benchmarks:__subpackages__"])
|
||||||
|
|
||||||
@ -30,3 +31,9 @@ ts_devserver(
|
|||||||
],
|
],
|
||||||
deps = [":ng2_switch"],
|
deps = [":ng2_switch"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
benchmark_test(
|
||||||
|
name = "perf",
|
||||||
|
server = ":devserver",
|
||||||
|
deps = ["//modules/benchmarks/src/largetable:perf_lib"],
|
||||||
|
)
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
|
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
|
||||||
load("//packages/bazel:index.bzl", "protractor_web_test_suite")
|
|
||||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
|
||||||
|
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
|
||||||
|
|
||||||
ng_module(
|
ng_module(
|
||||||
name = "largetable_lib",
|
name = "largetable_lib",
|
||||||
srcs = glob(
|
srcs = glob(["**/*.ts"]),
|
||||||
[
|
|
||||||
"**/*.ts",
|
|
||||||
],
|
|
||||||
exclude = ["protractor.on-prepare.ts"],
|
|
||||||
),
|
|
||||||
tags = ["ivy-only"],
|
tags = ["ivy-only"],
|
||||||
deps = [
|
deps = [
|
||||||
"//modules/benchmarks/src:util_lib",
|
"//modules/benchmarks/src:util_lib",
|
||||||
@ -42,23 +37,9 @@ ts_devserver(
|
|||||||
tags = ["ivy-only"],
|
tags = ["ivy-only"],
|
||||||
)
|
)
|
||||||
|
|
||||||
protractor_web_test_suite(
|
benchmark_test(
|
||||||
name = "perf",
|
name = "perf",
|
||||||
configuration = "//:protractor-perf.conf.js",
|
|
||||||
data = [
|
|
||||||
"//packages/bazel/src/protractor/utils",
|
|
||||||
"//packages/benchpress",
|
|
||||||
"@ngdeps//node-uuid",
|
|
||||||
"@ngdeps//protractor",
|
|
||||||
"@ngdeps//reflect-metadata",
|
|
||||||
"@ngdeps//yargs",
|
|
||||||
],
|
|
||||||
on_prepare = ":protractor.on_prepare.js",
|
|
||||||
server = ":devserver",
|
server = ":devserver",
|
||||||
tags = [
|
tags = ["ivy-only"],
|
||||||
"ivy-only",
|
deps = ["//modules/benchmarks/src/largetable:perf_lib"],
|
||||||
],
|
|
||||||
deps = [
|
|
||||||
"//modules/benchmarks/src/largetable:perf_lib",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
@ -1,22 +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
|
|
||||||
*/
|
|
||||||
|
|
||||||
const protractorUtils = require('@angular/bazel/protractor-utils');
|
|
||||||
const protractor = require('protractor');
|
|
||||||
|
|
||||||
module.exports = async function(config) {
|
|
||||||
const serverSpec = await protractorUtils.runServer(config.workspace, config.server, '-port', []);
|
|
||||||
|
|
||||||
const serverUrl = `http://localhost:${serverSpec.port}`;
|
|
||||||
// Since the browser restarts in this benchmark we need to set both the browser.baseUrl
|
|
||||||
// for the first test and the protractor config.baseUrl for the subsequent tests
|
|
||||||
protractor.browser.baseUrl = serverUrl;
|
|
||||||
|
|
||||||
const processedConfig = await protractor.browser.getProcessedConfig();
|
|
||||||
return processedConfig.baseUrl = serverUrl;
|
|
||||||
};
|
|
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": ["es2015"]
|
|
||||||
}
|
|
||||||
}
|
|
@ -31,6 +31,7 @@
|
|||||||
"payload_tests",
|
"payload_tests",
|
||||||
// Tests which are already migrated to Bazel:
|
// Tests which are already migrated to Bazel:
|
||||||
"playground/",
|
"playground/",
|
||||||
|
"benchmarks/src/largetable",
|
||||||
"benchmarks/src/tree"
|
"benchmarks/src/tree"
|
||||||
],
|
],
|
||||||
"angularCompilerOptions": {
|
"angularCompilerOptions": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user