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

View File

@ -22,7 +22,7 @@ import {BenchmarkableExpandingRowModule} from './benchmarkable_expanding_row_mod
<section>
<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>
</section>
@ -38,6 +38,8 @@ export class InitializationRoot implements AfterViewInit {
reset() { this.expandingRow.reset(); }
init() { this.expandingRow.init(); }
async runAll() {
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>
<script>
window.ngDevMode = location.hash == '#ngDevMode';
addEventListener('DOMContentLoaded', () => {
window.ngDevMode = location.hash == '#ngDevMode';
// 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
if (!alreadyBootstraped) {
function loadScript(url) {
var script = document.createElement('script');
script.src = url;
document.body.append(script);
return new Promise(function (resolve, reject) {
var script = document.createElement('script');
script.src = url;
script.onload = resolve;
script.onerror = reject;
document.body.append(script);
});
}
loadScript('/npm/node_modules/zone.js/dist/zone.js');
loadScript(document.location.search.endsWith('debug') ? 'bundle.min_debug.js' : 'bundle.min.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');
});
}
});
</script>

View File

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