fixup! test(ivy): make the test run with benchpress (#30449)

PR Close #30449
This commit is contained in:
Pawel Kozlowski 2019-05-14 10:03:21 +02:00 committed by Jason Aden
parent a5a1f4f52f
commit 98ded949dd
6 changed files with 51 additions and 42 deletions

View File

@ -1,5 +1,6 @@
package(default_visibility = ["//modules/benchmarks:__subpackages__"]) package(default_visibility = ["//modules/benchmarks:__subpackages__"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle") load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver") load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test") load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
@ -8,7 +9,7 @@ ng_module(
name = "application_lib", name = "application_lib",
srcs = glob( srcs = glob(
["**/*.ts"], ["**/*.ts"],
exclude = ["**/*_spec.ts"], exclude = ["**/*.spec.ts"],
), ),
deps = [ deps = [
"//packages:types", "//packages:types",
@ -19,14 +20,13 @@ ng_module(
], ],
) )
ng_module( ts_library(
name = "application_spec", name = "perf_lib",
srcs = glob(["**/*_spec.ts"]), testonly = 1,
srcs = ["benchmark_perf.spec.ts"],
deps = [ deps = [
"//packages:types", "//modules/e2e_util",
"//packages/common", "@npm//protractor",
"//packages/core",
"@npm//reflect-metadata",
], ],
) )
@ -69,6 +69,6 @@ benchmark_test(
name = "perf", name = "perf",
server = ":prodserver", server = ":prodserver",
deps = [ deps = [
":application_spec", ":perf_lib",
], ],
) )

View File

@ -22,7 +22,7 @@ import {BenchmarkableExpandingRowModule} from './benchmarkable_expanding_row_mod
<section> <section>
<button id="reset" (click)="reset()">Reset</button> <button id="reset" (click)="reset()">Reset</button>
<button (click)="handleInitClick()">Init</button> <button id="init" (click)="init()">Init</button>
<button id="run" (click)="runAll()">Run All</button> <button id="run" (click)="runAll()">Run All</button>
</section> </section>
@ -38,6 +38,8 @@ export class InitializationRoot implements AfterViewInit {
reset() { this.expandingRow.reset(); } reset() { this.expandingRow.reset(); }
init() { this.expandingRow.init(); }
async runAll() { async runAll() {
await execTimed('initialization_benchmark', async() => { await this.doInit(); }); await execTimed('initialization_benchmark', async() => { await this.doInit(); });
} }

View File

@ -0,0 +1,26 @@
/**
* @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 {$, browser} from 'protractor';
import {runBenchmark} from '../../../e2e_util/perf_util';
describe('benchmarks', () => {
it('should work for create', done => {
browser.rootEl = '#root';
runBenchmark({
id: 'create',
url: '',
ignoreBrowserSynchronization: true,
params: [],
prepare: () => $('#reset').click(),
work: () => $('#init').click()
}).then(done, done.fail);
});
});

View File

@ -1,24 +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 {$} from 'protractor';
import {openTreeBenchmark, runTreeBenchmark} from './tree_perf_test_utils';
describe('benchmarks', () => {
it('should work for createOnly', done => {
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);
});
});

View File

@ -14,19 +14,24 @@
<benchmark-root>loading...</benchmark-root> <benchmark-root>loading...</benchmark-root>
<script> <script>
addEventListener('DOMContentLoaded', () => {
window.ngDevMode = location.hash == '#ngDevMode'; window.ngDevMode = location.hash == '#ngDevMode';
addEventListener('DOMContentLoaded', () => {
// DevServer has automatic bootstrap code, so if we already have <scripts> than we don't need to bootstrap // DevServer has automatic bootstrap code, so if we already have <scripts> than we don't need to bootstrap
var alreadyBootstraped = document.querySelectorAll('script').length > 1; // 1 for ourselves var alreadyBootstraped = document.querySelectorAll('script').length > 1; // 1 for ourselves
if (!alreadyBootstraped) { if (!alreadyBootstraped) {
function loadScript(url) { function loadScript(url) {
return new Promise(function (resolve, reject) {
var script = document.createElement('script'); var script = document.createElement('script');
script.src = url; script.src = url;
script.onload = resolve;
script.onerror = reject;
document.body.append(script); document.body.append(script);
});
} }
loadScript('/npm/node_modules/zone.js/dist/zone.js'); // zone.js must be loaded and processed before Angular bundle gets executed
loadScript('/npm/node_modules/zone.js/dist/zone.js').then(function () {
loadScript(document.location.search.endsWith('debug') ? 'bundle.min_debug.js' : 'bundle.min.js'); loadScript(document.location.search.endsWith('debug') ? 'bundle.min_debug.js' : 'bundle.min.js');
});
} }
}); });
</script> </script>

View File

@ -34,7 +34,7 @@ exports.config = {
framework: 'jasmine2', framework: 'jasmine2',
jasmineNodeOpts: { jasmineNodeOpts: {
showColors: true, showColors: true,
defaultTimeoutInterval: 60000, defaultTimeoutInterval: 90000,
print: function(msg) { console.log(msg); }, print: function(msg) { console.log(msg); },
}, },
useAllAngular2AppRoots: true useAllAngular2AppRoots: true